using python interpreters per thread in C++ program

Mark Hammond skippy.hammond at gmail.com
Mon Sep 7 19:28:38 EDT 2009


On 8/09/2009 9:16 AM, Grant Edwards wrote:
> On 2009-09-07, Mark Hammond<skippy.hammond at gmail.com>  wrote:
>
>>> CPython's GIL means that multithreading on multiple
>>> processors/cores has limitations. Each interpreter has its own
>>> GIL, so processor-intensive applications work better using the
>>> multiprocessing module than with the threading module.
>>
>> I believe you will find the above is incorrect - even with
>> multiple interpreter states you still have a single GIL.
>
> Please explain how multiple processes, each with a separate
> Python interpreter, share a single GIL.


Sorry, my mistake, I misread the original - using multiple Python 
processes does indeed have a GIL per process.  I was referring to the 
'multiple interpreters in one process' feature of Python which is 
largely deprecated, but if used, all 'interpreters' share the same GIL.

To clarify: in a single process there will only ever be one GIL, but in 
multiple processes there most certainly will be multiple GILs.

Apologies for the confusion...

Cheers,

Mark




More information about the Python-list mailing list