[Pyrex] [Cython-dev] Callbacks from threads and PyGILState_Ensure/PyGILState_Release
Greg Ewing
greg.ewing at canterbury.ac.nz
Mon Sep 24 01:39:21 CEST 2007
Stefan Behnel wrote:
> Then we'd also have to disallow this for now:
>
> cdef int myfunc() nogil:
> with GIL:
> print("something")
> return 1 + 1
Probably, yes.
> That makes the "with GIL" block pretty redundant.
No, because by leaving it out but declaring the function
as 'nogil', as long as there are no Python arguments or
operations, you get a pure C function that can be called
without the GIL. That won't be checked in the initial
implementation, but it might be later, so it would be
best to get people into the habit of using nogil and
with GIL properly to begin with.
--
Greg
More information about the Pyrex
mailing list