I have a simulation that is currently running, but the ETA is about 40 hours -- I\'m trying to speed it up with multi-processing.
It essentially iterates over 3 valu
data of those tuplesf to process one tuple and return one resultp = multiprocessing.Pool() object.results = p.map(f, data)This will run as many instances of f as your machine has cores in separate processes.
Edit1: Example:
from multiprocessing import Pool
data = [('bla', 1, 3, 7), ('spam', 12, 4, 8), ('eggs', 17, 1, 3)]
def f(t):
name, a, b, c = t
return (name, a + b + c)
p = Pool()
results = p.map(f, data)
print results
Edit2:
Multiprocessing should work fine on UNIX-like platforms such as OSX. Only platforms that lack os.fork (mainly MS Windows) need special attention. But even there it still works. See the multiprocessing documentation.