[issue10915] Make the PyGILState API compatible with multiple interpreters

Antoine Pitrou report at bugs.python.org
Sun Jan 16 11:56:44 CET 2011

Antoine Pitrou <pitrou at free.fr> added the comment:

> The bulk of use cases is going to be simple callbacks via the same
> thread that called out of Python in the first place. [...]
> This is what SWIG effectively does in its generated wrappers for
> callbacks.

Thanks for clarifying. I agree the TLS scheme would help in these cases.
There is still the question of what/who updates the TLS mapping; you are
proposing a new API call; an alternative is to do the mapping in e.g.

> The reality is that if you force a change on every single extension
> module doing callbacks into the interpreter without having the GIL
> first, you will never see people update their code as they will likely
> not care about this special use case. And so the whole point of adding
> the additional APIs will be wasted effort and have achieved nothing.

I'm not sure I care. If people don't want to use the new APIs on the
basis that they are slightly more complex, then it's their problem. The
Python C API tries not to be too cumbersome, but it cannot pretend to be
as transparent as a high-level API in a dynamic language.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list