Robert Bradshaw, 17.08.2011 20:19:
I have to admit that all these special gil
declarations are a bit messy. I'd also rather introduce clear
decorators, e.g.

@cython.requires_gil  # expects gil
cdef a(): ...

@cython.requires.gil(False) # nogil
cdef b(): ...

@cython.aquires_gil  # with gil
cdef c(): ...

The last would spell "@cython.aquire_gil", and yes, it totally makes sense to turn these into decorators. There's no reason at all why pure mode needs to differ from Cython mode here (however tricky it may be to write a GIL free function in pure mode...).


(Actually, now that we have the "with gil" statement, it could be
worth considering simply noticing the pattern of the entire function
body in a with gil block/as the first statement and acquiring the GIL
before argument parsing.)

Agreed.


Note that we need to declare functions as requiring the GIL to allow
for declaring cpython.pxd if extern functions are implicitly nogil.

Yes, I thought of that, too. In the specific case of .pxd files for external C libraries, a special "requires gil" syntax makes sense, as you'd want to put it at the "cdef extern" declaration once, instead of having to add a decorator to each of the declared functions.

Stefan
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to