5,321
edits
Line 329: | Line 329: | ||
===concurrrency=== | ===concurrrency=== | ||
In Python 3.2 <code>concurrent.futures</code> gives you access to thread pools. | In Python 3.2+, [https://docs.python.org/3/library/concurrent.futures.html#module-concurrent.futures <code>concurrent.futures</code>] gives you access to thread pools. | ||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
Line 353: | Line 353: | ||
* <code>len(os.sched_getaffinity(0))</code> returns the number of threads available to the Python process. | * <code>len(os.sched_getaffinity(0))</code> returns the number of threads available to the Python process. | ||
* Starting in Python 3.5, if <code>max_workers</code> is none, it defaults to <code>5 * os.cpu_count()</code>. | * Starting in Python 3.5, if <code>max_workers</code> is none, it defaults to <code>5 * os.cpu_count()</code>. | ||
* <code>executor.shutdown()</code> will wait for all jobs to finish but you cannot submit any additional jobs | * <code>executor.shutdown()</code> will wait for all jobs to finish but you cannot submit any additional jobs from other threads, after calling shutdown. | ||
==Data Structures== | ==Data Structures== |