Skip to content

Instantly share code, notes, and snippets.

@korymath
Forked from alertor/parallel.py
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korymath/49542788abf60a6e90ca to your computer and use it in GitHub Desktop.
Save korymath/49542788abf60a6e90ca to your computer and use it in GitHub Desktop.
from joblib import Parallel, delayed
import multiprocessing
inputs = range(100000)
def processInput(i):
return i * i
num_cores = multiprocessing.cpu_count()
print str(num_cores)
results = Parallel(n_jobs=num_cores)(delayed(processInput)(i) for i in inputs)
print results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment