Created
June 7, 2014 02:39
-
-
Save ccorcos/07398ae92c9ab305fb65 to your computer and use it in GitHub Desktop.
parallel processing in python
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 multiprocessing import Pool | |
def f(x): | |
print x | |
return x**2 | |
if __name__ == '__main__': | |
# 8 processors | |
p = Pool(8) | |
a = range(100) | |
b = p.map(f, a) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment