I have a python
script which loads a list of strings (very long list) into an array. I need to perform several operations on each element of the array. There are three operations that I need to do on each element: (1) count the length of the string, (2) multiply that by a scalar, and (3), take a mod of that.
This is very-very simple to do using a loop, but because I have so many elements in my array, I am wondering if there is a better way to do this that a simple for loop. I need it to be fast, and looping through millions of elements doesn't seem like the most efficient way to manage this.
Does anyone know of any way to optimize the performance in this kind of scenario using Python
?
Threading? Or is there an array iterator operator that I might not have heard of?
(I know this sounds like a homework problem, but it's not, I assure you. It's just a very simplified version of what I need to accomplish).
Any advice would be most appreciated! Thanks!
It must be done with a loop. Use a faster loop.