[Cython] Calling gil-requiring function not allowed without gil

Stefan Behnel stefan_ml at behnel.de
Thu Aug 18 09:06:39 CEST 2011


Dag Sverre Seljebotn, 18.08.2011 08:39:
> The semantics are simple: For all cdef functions, if "nogil" could have
> been applied without a syntax error, then it gets automatically applied.
>
> The only time this isn't completely safe is when the GIL is intentionally
> being used as a lock.

In which case, IMHO, it's actually a good idea to require an explicit 
declaration, because it makes this intention explicitly visible in the 
source code.

I take it that auto-nogil semantics for a function wouldn't automatically 
*release* the GIL. They'd just not require it, right? So all that would 
change is that you wouldn't get a compiler error when calling such a 
function without holding the GIL.

That shouldn't break all that much code...

Stefan


More information about the cython-devel mailing list