Python threads: backed by OS threads?
Andrew Maizels
andrew at one.net.au
Thu May 11 05:17:40 EDT 2000
Courageous wrote:
> I just read that. It suggests that the threads may
> be mutually locking eachother out some of the time,
> but it does not say that they will not see a performance
> gain once you discount the contention issues.
>
> In particular, the brief discussion might suggest to
> this otherwise naive reader that if the threads were
> operating in relative mutual exclusion to eachother and
> objects which, once divided between them, were non-
> co-referencial, here might not be as much contention
> for python locking structures as the document mentions.
Unfortunately, the locking mechanism is very simple: it doesn't know
whether you're going to run into trouble or not, so it always acquires
the lock so that only one thread of Python code can run at any time.
However, I/O operations can effectively multithread, so if you're doing
a lot of I/O, you may see a performance improvement. One of my programs
ran up to 80% faster when moved from a single-processor to a
dual-processor machine.
Andrew.
--
.sig still missing! No film at 11!
More information about the Python-list
mailing list