[Cython] Why is 'with gil' disabled in the parser? Any good reason?
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Mar 6 10:45:46 CET 2009
Lisandro Dalcin wrote:
> Supose you have a a pure C functions (I mean, no Py stuff), perhaps
> even declared 'with gil' in its signature... Now suppose that
> function access some global variables, then we would be able to get
> some sort of (global) locking using a 'with gil' block. Am I being
> clear? Do this make sense? Would this be useful?
Hmmm... you'd be creating a third kind of state, as well
as 'gil held' and 'gil not held', there would be 'gil
held but you're still not allowed to mess with Python
stuff in this function'. Sounds a bit messy to me.
It would be better to create an intermediate function
declared 'with gil' and call that from the nogil
function. Then the intermediate function will run
with the gil held.
Also, I wouldn't like to build in a language feature
whose only purpose in life is to enable abusing the
gil for non-python purposes. A 'with gil' block ought
to deliver all that it seems to promise, or not be
there.
--
Greg
More information about the Cython-dev
mailing list