I have got a chunk of code like
for i in range(0, len(a))
b[i] = func(a[i])
where a and b are arrays of the same length, a is given (and big), func is some function that has a lot of local variables but does not use any global variables.
I would like to distribute computations of func across several CPUs. Presumably I need to use multiprocessing module, but I have not found any relevant examples. Could you help? Thanks.
forkis problematic because it doesn't have an easy way of getting results back to the parent process.