Thomas Womack <tw*****@chiark .greenend.org.u k> wrote in
news:vQ*******@ news.chiark.gre enend.org.uk:
If I have a dual-processor hyperthreaded machine (so with four CPU
contexts), will a python program distribute threads over all four
logical processors?
I ask because I'm fairly sure that this *does* happen using the
threading extensions in MFC, and fairly sure that it *doesn't* when
using Java, so I don't see that the result is obvious for python.
The C implementation of Python uses a global interpreter lock that only
allows one thread to interpret bytecode at a time, so while the threads may
be distributed across multiple processors you will get little or no speedup
over a single processor. (If your threads spend most of their time in a
non-Python extension, they may be able to get some benefit from multiple
processors).
The only way to take advantage of multiple processors with Python is to run
at least one separate process for each processor. For example, I believe
Zope will take advantage of multiple processor systems if you run it in ZEO
client/server mode with several Zope client processes.
I believe that Jython simply does whatever the Java implementation does.
--
Duncan Booth
du****@rcp.co.u k
int month(char *p){return(1248 64/((p[0]+p[1]-p[2]&0x1f)+1)%12 )["\5\x8\3"
"\6\7\xb\1\x9\x a\2\0\4"];} // Who said my code was obscure?