I have the following code that I want to speed up (using multiprocessing).
def main(arg1):
data=[]
#Calculate new argument arg2
for i in range(n):
data.append(function(z,i,arg2))
Where z in a 2D array.
My idea was to do it the following way, but I am not sure this will speed up the process.
from multiprocessing import Pool
import itertools
def function_star(a_b_c):
return function(*a_b_c)
def main(arg1):
#Calculate new argument arg2
pool=Pool()
i=range(n)
out=pool.map(function_star, i, itertools.repeat(z),itertools.repeat(arg2) )
pool.close()
if __name__=="__main__":
main(arg1)
Is this indeed the most efficient way to speed up the process?