Multi-threading on Multi-CPU machines
Duncan Booth
duncan at NOSPAMrcp.co.uk
Tue Jul 9 08:50:29 EDT 2002
gtaylor at lowebroadway.com (Garry Taylor) wrote in
news:f0fd5987.0207090102.7362dd27 at posting.google.com:
> 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?
>
Can you split your program into several communicating processes? Each
process has its own GIL, so if you can run multiple processes they can make
better use of CPU.
The only other option really is to see if you can isolate CPU intensive
sections and rewrite them in C, then you might be able to release the GIL
enough to get a useful speedup.
Then again it may be possible to get enough speed improvement by modifying
existing code. I find it can be quite hard working out exactly where Python
is spending all its time. Do you know where in your current code most of
the CPU is actually used?
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list