[Python-Dev] GIL required for _all_ Python calls?

Stefan Behnel stefan_ml at behnel.de
Thu Jan 7 15:05:23 CET 2010

MRAB, 07.01.2010 04:07:
> I've been wondering whether it's possible to release the GIL in the
> regex engine during matching.
> I know that it needs to have the GIL during memory-management calls, but
> does it for calls like Py_UNICODE_TOLOWER

Py_UNICODE_TOLOWER looks safe to me at first glance.

> or PyErr_SetString?

Certainly not safe.

> Is there an easy way to find out?

Release it and fix any crashes? Note that this isn't a safe solution, 
though, as some GIL requiring code may be platform specific. So a better 
approach might be to extract any obviously problematic stuff from the 
existing code (such as any exception handling, explicit ref-counting or 
object creation), and *then* try to release the GIL.


More information about the Python-Dev mailing list