News for hackers. Stuff that matters.
Re:Ask YC:Python and Dual core Processors by swoodtke on Friday June 13, 2008 @09:20AM (#216736)
The Global Interpreter Lock (GIL) is exactly what is seems to be: a single python interpreter only allows one thread to run a one time regardless of the number of CPUs or cores available.

This lock is per instance of the python interpreter. Multiple instances will have a corresponding number of locks.

There are a couple of ways to have python use multiple cores or CPUs.

The first is to run multiple python instances and have them communicate between themselves using IPC mechanisms (e.g. sockets, pipes, shared memory, etc.). The non-standard "processing" module implements this very cleanly using a similar interface to the standard "threading" module.

The second is to extend Python using C and explicitly release the GIL inside the C extension. This allows both the C extension code and the Python interpreter to run simultaneously. However, the GIL will need to be reacquired before the C extension can resume any interaction with the Python interpreter.

There are no comments on this comment yet.