[Pyrex] Pyrex and the GIL

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Sep 7 05:58:26 CEST 2005


Simon Burton wrote:

> And inversely: some syntax to indicate that a particular c function
> call can release the GIL.

That's actually where I came from initially on this.
I was thinking of having a declaration like

   cdef extern int foo(int blarg) nogil

where "nogil" means "this function expects the GIL to be
released when it is called". Whenever it is called in a
Pyrex function, code would be generated to release the
GIL, call the function, and then re-acquire the GIL.

Then I realised that the *same* declaration could be
used the other way round, too. If you write

   cdef void my_callback() nogil
     ...code here...

you're saying "the GIL will be released when this
function is called". So Pyrex will generate code to
acquire the GIL before executing the function body
and release it again afterward.

Is that neat? Or too confusing?

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+



More information about the Pyrex mailing list