I have a function that encrypts a number and stores it in an list
encrypted = [[0]*10]*1000
def encrypt(i):
encrypted[i]=bin(i)[2:].zfill(10).decode('hex')
The expression is much more complex than this. I am just stating an example.
Now I want to call the encrypt function inside a for loop with multiple calls in different processes or threads - however due to GIL for CPU bound process, threads wont help - correct me if i am wrong.
for i in xrange(1000):
encrypt(i)
So The loop should not wait for the encryption of one value to get over, for the next to start.
So when i=1 and encryption of 1 is taking place, For loop should increment and start encrypting 2, and then 3 simultaneously.
The results of encryption should be stored in encrypted list (order of results is not important).