Status of Python threading support (GIL removal)?

Piet van Oostrum piet at cs.uu.nl
Sat Jun 20 10:45:08 CEST 2009


>>>>> Jure Erznožnik <jure.erznoznik at gmail.com> (JE) wrote:

>JE> I have shown my benchmarks. See first post and click on the link.
>JE> That's the reason I started this discussion.

>JE> All I'm saying is that you can get threading benefit, but only if the
>JE> threading in question is implemented in C plugin.
>JE> I have yet to see pure Python code which does take advantage of
>JE> multiple cores. From what I read about GIL, this is simply impossible
>JE> by design.

In fact, at least theoretically, your original application could benefit
from multiple cores. Take this scenario:

You have one thread that reads from a file. On each read the GIL is
released until the read has completed. In the meantime the other thread
could do some CPU-intensive work. Now if the read comes entirely from
the O.S. cache it is also CPU-bound. So there a second core comes in
handy. Now usually these reads will not consume so much CPU so it will
probably be hardly noticeable. But if you would have some kind of
CPU-intensive User-space File System, for example with compression
and/or encryption and the data is in memory you might notice it. In this
example all your application code is written in Python.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list