Multi-threading on Multi-CPU machines

Joseph A Knapka jknapka at earthlink.net
Mon Jul 8 16:57:52 EDT 2002


Garry Taylor wrote:
> 
> Hello,
> I am attempting to make a multi-threading function in one of my
> programs in an effort to gain a speed increase, but I'm getting quite
> the opposite, even on a dual-CPU Intel/Linux box. Can anyone enlighten
> me as to why,

Yes. CPython threads cannot utilize multiple CPUs, due to the
Global Interpreter Lock, which may only be acquired by one
thread at a time. Apparently Jython threads do not have
this limitation, as the GIL doesn't exist in Jython, or so
I'm told. So if you simply ran your program under Jython
you might see an improvement.

Cheers,

-- Joe



More information about the Python-list mailing list