Skip to content

Instantly share code, notes, and snippets.

@alertor
Created September 11, 2014 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alertor/df4323f56f038f8839e6 to your computer and use it in GitHub Desktop.
Save alertor/df4323f56f038f8839e6 to your computer and use it in GitHub Desktop.
python parallel jobs
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