<story><title>Parallel Programming with Python</title><url>https://chryswoods.com/parallel_python/index.html</url></story><parent_chain></parent_chain><comment><author>quietbritishjim</author><text>In response to the multiple comments here complaining that multithreading is impossible in Python without using multiple processes, because of the GIL (global interpreter lock):&lt;p&gt;This is just not true, because C extension modules (i.e. libraries written to be used from Python but whose implementations are written in C) can release the global interpreter lock while inside a function call. Examples of these include numpy, scipy, pandas and tensorflow, and there are many others. Most Python processes that are doing CPU-intensive computation spend relatively little time actually executing Python, and are really just coordinating the C libraries (e.g. &amp;quot;mutiply these two matrices together&amp;quot;).&lt;p&gt;The GIL is also released during IO operations like writing to a file or waiting for a subprocess to finish or send data down its pipe. So in most practical situations where you have a performance-critical application written in Python (or more precisely, the top layer is written in Python), multithreading works fine.&lt;p&gt;If you are doing CPU intensive work in pure Python and you find things are unacceptably slow, then the simplest way to boost performance (and probably simplify your code) is to rewrite chunks of your code in terms of these C extension modules. If you can&amp;#x27;t do this for some reason then you will have to throw in the Python towel and re-write some or all of your code in a natively compiled language (if it&amp;#x27;s just a small fraction of your code then Cython is a good option). But this is the best course of action regardless of the threads situation, because pure Python code runs orders of magnitude slower than native code.</text></comment>
<story><title>Parallel Programming with Python</title><url>https://chryswoods.com/parallel_python/index.html</url></story><parent_chain></parent_chain><comment><author>elcombato</author><text>&amp;gt; (note that you must be using Python 2 for this workshop and not using Python 3. Complete this workshop using Python 2, then read about the small changes if you are interested in using Python 3)&lt;p&gt;Why using legacy Python for this?</text></comment>