threading support in python

Jean-Paul Calderone exarkun at divmod.com
Mon Sep 4 12:01:30 EDT 2006


On Mon, 4 Sep 2006 17:48:14 +0200, Sybren Stuvel <sybrenuse at yourthirdtower.com.imagination> wrote:
>km enlightened us with:
>> Is there any PEP to introduce true threading features into python's
>> next version as in java? i mean without having GIL.
>
>What is GIL? Except for the Dutch word for SCREAM that is...
>
>> when compared to other languages, python is fun to code but i feel
>> its is lacking behind in threading
>
>What's wrong with the current threading? AFAIK it's directly linked to
>the threading of the underlying platform.

Only one thread per process can execute Python bytecode, even on an SMP
system.  The main bytecode eval loop is protected by a lock, the "Global
Interpreter Lock".

This doesn't prevent certain operations from being parallelized.  For
example, many of the I/O calls in Python release the GIL so that while
they are blocked on the network or the disk, another thread can continue
to execute.  Extension modules which perform computationally intensive
tasks can also release the GIL to allow better exploitation of SMP
resources.

Jean-Paul



More information about the Python-list mailing list