[Python-Dev] Threading in the Standard Library Tour Part II
aahz at pythoncraft.com
Mon Aug 16 05:48:17 CEST 2004
On Sun, Aug 15, 2004, Raymond Hettinger wrote:
> All that being said, a few cautions are in order. Thread programming is
> difficult to get right. And, its overhead decreases total application
> performance. Also, multiple processors cannot boost performance because
> Python's Global Interpreter Lock (GIL) precludes more than one thread
> from running in the interpreter at the same time (this was done to
> simplify re-entrancy issues). Another issue is that threading doesn't
> work with the event driven model used by most GUIs.
Python threading certainly does work with GUIs, and while the GIL adds
some difficulty, the overall simplicity of Python's thread model makes
it easier to get threaded GUI programs correct. See the Tkinter example
from my OSCON slides.
I'll also emphasize what Tim said: the GIL allows only one Python
thread, but any external library can release the GIL to perform threaded
operations in parallel. In particular, I/O libraries almost always
release the GIL (I believe this includes mxODBC, for example).
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"To me vi is Zen. To use vi is to practice zen. Every command is a
koan. Profound to the user, unintelligible to the uninitiated. You
discover truth everytime you use it." --reddy at lion.austin.ibm.com
More information about the Python-Dev