threads

Hrvoje Niksic hniksic at srce.hr
Fri Jun 4 11:57:38 CEST 1999


"Andrew M. Kuchling" <akuchlin at mems-exchange.org> writes:

> Hrvoje Niksic writes:
> >Jeremy Hylton <jeremy at cnri.reston.va.us> writes:
> >> The short answer is no.  The Python interpreter has a lock that
> >> prevents allows only a single thread to execute at a time.
> >
> >Eek.  That's depressing.  Isn't supporting threads and not allowing
> >simultaneous execution a bit weird?
> 
> I don't think so, because the common case is probably not the one
> where lots of work is being done in Python code.

Well, I do think so.  The "common case" may be that lot of work is not 
done in Python code, but maybe such common cases emerge from lousy
execution to begin with.

Dividing threaded programs to IO-heavy and computation-heavy misses
the point because many realistic cases have some of both -- for
instance, an internet server under heavy load.  Python's
characteristics make it quite suitable for such a purpose, and having
threads lock each other off is a _definite_ minus on a multi-CPU
machine.

Maybe it would be possible to make the actual interpreter thread-safe,
and only lock when an extension of unknown thread-safety is called.




More information about the Python-list mailing list