Multi-threading on Multi-CPU machines

Garry Taylor gtaylor at lowebroadway.com
Tue Jul 9 05:02:38 EDT 2002


Joseph A Knapka <jknapka at earthlink.net> wrote in message news:<3D29FC43.C239BD5F at earthlink.net>...
> 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

Thank you both for your anwsers, unfortunatly running under Jython is
not an option, as the whole program which I am writing runs to about
5,000 lines and use lots of Python modules which I don't really fancy
trying to get to work under Jython.

So, am I correct in thinking that there is nothing I can do about
this, and still use standard Python? I understand that Solaris has a
very good threading library, but from the comments above, I assume
that this would make no difference? Do you have any tips/ideas how I
could make use of multiple processors in a Python program?

Thanks again

Garry



More information about the Python-list mailing list