Solving the problem of mutual recursion

Ian Kelly ian.g.kelly at gmail.com
Mon May 27 02:19:30 EDT 2013


On Sun, May 26, 2013 at 4:16 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Mon, May 27, 2013 at 5:35 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
>> I'm pretty sure that CPython uses the GIL regardless of platform.  And
>> yes you can have multiple OS-level threads, but because of the GIL
>> only one will actually be running at a time.  Other possibilities
>> include:
>
> 6) It's spinning in a function that has released the GIL. Python
> threads can certainly execute concurrently; they just can't be
> manipulating Python objects. Most of the I/O functions will release
> the GIL before doing a potentially-blocking operation, and some
> CPU-heavy functions can do the same (I'm given to understand that
> numpy does this) - just depends on having a long job that involves no
> refcounted objects.

7) Since the program being tested does basically nothing except start
and exit threads, the extra 40% probably represents the overhead of
all that starting and stopping, which would be done outside the GIL.



More information about the Python-list mailing list