Created
July 12, 2018 05:36
-
-
Save zed/bcccd63189d53c544d0ed143c711015c to your computer and use it in GitHub Desktop.
jupyter notebook + multiprocesssing.Pool (on Linux)
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"oneone twotwo treetree\n" | |
] | |
} | |
], | |
"source": [ | |
"from multiprocessing import Pool\n", | |
"\n", | |
"def double(s):\n", | |
" return s*2\n", | |
"\n", | |
"with Pool() as pool:\n", | |
" print(*pool.map(double, [\"one\", \"two\", \"tree\"]))" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment