[Python-Dev] Threading in the Standard Library Tour Part II
Bob Ippolito
bob at redivi.com
Mon Aug 16 05:44:23 CEST 2004
On Aug 15, 2004, at 11:38 PM, Stephen J. Turnbull wrote:
>>>>>> "Raymond" == Raymond Hettinger <python at rcn.com> writes:
>
> Raymond> Threading is a technique for decoupling tasks which are
> Raymond> not sequentially dependent and creating the illusion of
> Raymond> concurrency.
>
> All simultaneity is an illusion, but the concurrency of Python threads
> is not. <wink>
>
> 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 think it's worth mentioning. It's absolutely necessary to know all
about the GIL when writing an extension that can take advantage of
threading or embed Python correctly in a threaded application.
-bob
More information about the Python-Dev
mailing list