[Python-Dev] Re: Threading in the Standard Library Tour Part II

Mike Coleman mkc at mathdogs.com
Mon Aug 23 01:57:20 CEST 2004


"Stephen J. Turnbull" <stephen at xemacs.org> writes:
> >>>>> "Raymond" == Raymond Hettinger <python at rcn.com> writes:
>     Raymond> Also, multiple processors cannot boost performance
>     Raymond> because Python's Global Interpreter Lock (GIL) precludes
>     Raymond> more than one thread from running in the interpreter at
>     Raymond> the same time (this was done to simplify re-entrancy
>     Raymond> issues).
> 
> This confused me because "running" is ambiguous.  How about something
> like:
> 
>     The Python interpreter itself is not fully reentrant, so threading
>     is accomplished by interleaving the execution of Python code from
>     different threads.  Thus, use of multiple processors cannot boost
>     performance of threaded Python code, because a single instance of
>     the interpreter can only execute code on one processor at a time.
> 
> (Season to taste, fix technical inaccuracies.)  I see no reason to
> mention the GIL, an implementation detail, at all.

I somewhat prefer Raymond's version, myself.  As soon as I read "execute code
on one processor at a time", I immediately want to ask "Why?".  The mention of
the GIL more or less answers this, depending on how much you know about
interpreters.

Mike




More information about the Python-Dev mailing list