Hi,<br><br>When you say this "C extensions (usually) release the GIL when they don't call into any Python code" do you talk about this macros ?<br><pre>Py_BEGIN_ALLOW_THREADS<br><br>Py_END_ALLOW_THREADS<br><br>
</pre><pre><br></pre><br><div class="gmail_quote">On Wed, Jun 11, 2008 at 3:52 AM, Gabriel Genellina <<a href="mailto:gagsl-py2@yahoo.com.ar">gagsl-py2@yahoo.com.ar</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
En Mon, 09 Jun 2008 15:26:09 -0300, Pau Freixes <<a href="mailto:pfreixes@gmail.com" target="_blank">pfreixes@gmail.com</a>> escribió:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
Surly this is a recurring theme into python dev world, but I need your help<br>
for confirm if the follow image it's really<br>
<br>
</div><a href="http://www.milnou.net/%7Epfreixes/img/cpu_usage_gil_problem.png" target="_blank">http://www.milnou.net/~pfreixes/img/cpu_usage_gil_problem.png</a><<a href="http://www.milnou.net/%7Epfreixes/img/cpu_usage_gil_problem.png" target="_blank">http://www.milnou.net/%7Epfreixes/img/cpu_usage_gil_problem.png</a>><div class="Ih2E3d">
<br>
<br>
I'm writing a brief article for my blog and I need to make sure about the<br>
current problem with GIL and multi core environments, this picture try to<br>
explain with images the problem for scheduling multiple threads running<br>
python code of same interpreter into multiple cpu cores. Can  anyone confirm<br>
to me this picture ?<br>
</div></blockquote>
<br>
Yes, if both threads are executing pure Python code, they can't run simultaneously.<br>
<br>
Note that:<br>
- C extensions (usually) release the GIL when they don't call into any Python code<br>
- The interpreter also releases the GIL before any I/O operation<br>
If the process is I/O bound then the GIL is not so important, and if it's CPU bound you may benefit from reimplementing the critical parts in C (by example, using NumPy for a number-crunching process). Another alternative is to use multiple processes with some form of IPC instead of multiple threads.<br>

These are the usual arguments against "fear of GIL". You should consider your specific application to see if the GIL is actually a problem in your case or not.<br>
<br>
-- <br>
Gabriel Genellina<br><font color="#888888">
<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Pau Freixes<br>Linux GNU/User