What is situation with threads in Python

Jp Calderone exarkun at divmod.com
Mon Apr 25 14:19:18 EDT 2005


On Mon, 25 Apr 2005 10:46:57 -0700, "Leonard J. Reder" <reder at jpl.nasa.gov> wrote:
>Hello Mark,
>
>I took your three day course here at JPL and recall that you said something 
>was wrong with the implementation of threads within Python
>but I cannot recall what.  So what is wrong with threads in Python?

  Nothing is wrong with threads, really.  What is often considered wrong is how well the interpreter mainloop can exploit them.  There is a single lock (the [G]lobal [I]interpreter [L]ock) which must be acquired to execute any Python bytecode.  This effectively serializes most Python programs.  Notable exceptions to this include most IO related operations (opening files, reading from sockets, etc), which explicitly release the lock during the actual IO operations, so as to allow other threads to execute Python bytecode while waiting on the disk or the network.

  Jp



More information about the Python-list mailing list