[pypy-dev] GIL in cpyext extensions

Stefan Behnel stefan_ml at behnel.de
Wed Mar 14 21:04:21 CET 2012


I stumbled over the following paragraph in


PyEval_SaveThread() always return NULL in pypy.  But I don't know if there
is a better value, since the GIL is always released in C code.

Why should the GIL always be released? There are many C extensions that use
it in one way or another to protect their internal state, to implement fast
(optimistic) locking, or whatever. In order to be compatible with them, the
GIL should be held unless explicitly released, just like CPython does it.

Granted, in many cases, it wouldn't have to be the GIL, it could just be a
separate "C code lock". But it's impossible to take this decision in general.


More information about the pypy-dev mailing list