Parallelizing a Numpy vector operation
Let's use, for example, numpy.sin() The following code will return the value of the sine for each value of the array a : import numpy a = numpy.arange( 1000000 ) result = numpy.sin( a ) But my machine has 32 cores, so I'd like to make use of them. (The overhead might not be worthwhile for something like numpy.sin() but the function I actually want to use is quite a bit more complicated, and I will be working with a huge amount of data.) Is this the best (read: smartest or fastest) method: from multiprocessing import Pool if __name__ == '__main__': pool = Pool() result = pool.map( numpy.sin, a