Python threads: backed by OS threads?

Konrad Hinsen hinsen at cnrs-orleans.fr
Thu May 11 20:33:22 CEST 2000


Courageous <jkraska1 at san.rr.com> writes:

> Okay, I simply have to know for sure that Python
> threads are backed by full operating system threads.

They are.

> To wit: if I create multiple Python threads on a
> machine with multiple CPUs, I should be expecting
> take advantage of the additional CPU's, correct?

Not necessarily. The Python interpreter is not fully thread-safe,
therefore only one thread at a time can execute interpreted Python
code. The only way to take advantage of multiple CPUs is by executing
time-consuming C code, called from Python after releasing the
interpreter lock. The details are explained in the Extending & Embedding
manual at www.python.org.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------



More information about the Python-list mailing list