Created
September 11, 2014 11:00
-
-
Save alertor/df4323f56f038f8839e6 to your computer and use it in GitHub Desktop.
python parallel jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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