[Python-Dev] Feature Request: Py_NewInterpreter to create separate GIL (branch)

"Martin v. Löwis" martin at v.loewis.de
Sat Nov 4 09:49:53 CET 2006


Robert schrieb:
> Would it be a possibilty in next Python to have the lock separate for
>  each Interpreter instance. Thus: have *interpreter_lock separate in
> each PyThreadState instance and only threads of same Interpreter have
> same GIL? Separation between Interpreters seems to be enough. The
> Interpreter runs mainly on the stack. Possibly only very few global
> C-level resources would require individual extra locks.

Notice that at least the following objects are shared between
interpreters, as they are singletons:
- None, True, False, (), "", u""
- strings of length 1, Unicode strings of length 1 with ord < 256
- integers between -5 and 256
How do you deal with the reference counters of these objects?

Also, type objects (in particular exception types) are shared between
interpreters. These are mutable objects, so you have actually
dictionaries shared between interpreters. How would you deal with these?

Also, the current thread state is a global variable, currently
(_PyThreadState_Current). How would you provide access to the current
thread state if there are multiple simultaneous threads?

Regards,
Martin


More information about the Python-Dev mailing list