Jython, GILs and object locking.

Jon Franz_antispam jfranzXREMOVEX at neurokode.com
Fri Oct 10 17:37:37 EDT 2003


Michael Chermside <mcherm at mcherm.com> wrote:
> Ahh... but with this YOU are going too far. Just because the
> GIL *is* an actual problem, doesn't mean that it's a *big*
> problem. In particular, it *IS* okay to do threaded programming
> in python. People do it all the time, including some very
> large applications (Zope comes to mind) that make heavy use
> of threading.

Yes, and I'm willing to bet 5$ that the Zope developers would
love a true freethreaded interpreter, since Zope is limited on
big hardware by the GIL-ized interpreter preventing multiple CPUs
being used.  Using ZEO to run multiple copies of Zope localy
on the same datastore is a silly workaround.

> You see, there are multiple reasons for using threads. One
<< SNIP >>
> Another reason would be that you have a spiffy new computer
> with multiple processors and you want to get the most out
<< SNIP >>
> might not mind whether it takes 0.5 seconds versus 0.25.

I see a big gaping hole in your list of reasons for needing threads.
Big, I/O bound network servers can benefit greatly from
threads on multiple CPUs.  Multi-process programming is
not for everyone, and has its own issues it introduces to
the mix when you attempt to write applications with it.

I think, however, that until (IF) the GIL is removed, a
simple documentation change could be very useful.  That
is, in the thread module docs, and the tutorials (and
anyplace that mentions threading) mention that python, due to 
the GIL, cannot use multiple processors.  This would prevent the
scenario described by Luis P Caamano, or at least help deflect it
earlier in the development cycle.  I know that many developers
see thread support in the standard library and assume that it
will help them utilize multiple CPUs.  Even if they want to do
it for the wrong reasons, they make that assumption.  

Not mentioning it outright is probably (or at least partialy)
why people get so pushy about it when they come onto the list,
because they find out too late that a descision they made early-on
is about to bite them in the arse.

I propose we revise the docs - it won't hurt anything to do it. 

> The thing is... there are lots fewer people in this situation
> than there are people who THINK they are in this situation.

This is true, but probably not as true as you think.  No offense.

~Jon Franz
Neurokode Labs, LLC






More information about the Python-list mailing list