Skip to content

Instantly share code, notes, and snippets.

@podolskyi
Forked from lxneng/gist:555aadfa60e2656df320
Created February 24, 2016 13:23
Show Gist options
  • Save podolskyi/60d52fbd92ecc269a3d1 to your computer and use it in GitHub Desktop.
Save podolskyi/60d52fbd92ecc269a3d1 to your computer and use it in GitHub Desktop.
Simple Python Parallelism
from multiprocessing import Pool
from functools import partial
def parallel_function(f):
def parallize(f, seq):
pool = Pool()
pool.map(f, seq)
pool.close()
pool.join()
return partial(parallize, f)
def test(n):
print(n+1)
test.parallel = parallel_function(test)
test.parallel(range(1000000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment