Global Interpreter Lock

Martin v. Löwis loewis at
Wed Sep 11 16:30:04 EDT 2002

codic at (Ian Crawford) writes:

>     I'm working on a project with an embedded Python
> interpreter which I'd like to be capable of parallel
> execution on a multi-processor machine.  I'm still
> trying to figure out one thing in particular.  Is
> there a global interpreter lock per interpreter (i.e.
> if I call Py_NewInterpreter, does that interpreter
> have it's own lock), or will I have to embed seperate
> interpreters in their own processes to have parallel
> execution?

The latter: even if you have multiple interpreter objects, the Python
runtime still needs to protected with a single lock.

Notice that you can have multiprocessor parallelism in Python if the
threads invoke long-running C code: if the extension module releases
the interpreter lock before the compute-intensive C code starts, this
computation can be performed on a separate processor.


More information about the Python-list mailing list