[Pyrex] Pyrex and the GIL

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Sep 12 11:45:58 CEST 2005


Andrew Bennetts wrote:

> You're talking about case 1, and I'm happy enough with "nogil" for that.  I
> think "ensures_gil" would be a saner name for case 2, though -- after all,
> I presume it would be implemented using PyGILState_Ensure, which exists for
> that purpose.

Perhaps, although we're back to the question of whether
it's worth explicitly providing for a "don't care" case.
It's not strictly necessary, since if it doesn't care,
it does no harm to release the GIL before calling it,
should it ever be called directly from Pyrex code.

An important thing to keep in mind is that these are
properties of the function signature, and whatever
names they're given, they need to make sense from both
inside and outside the function, and whether the function
is implemented in Pyrex or not. So, for example,
"ensures_gil" is not appropriate, because it says
something about the function's implementation, not
its signature.

If there is to be a don't-care case, its name needs
to be a short word (preferably without underscores)
that means "doesn't care whether the GIL is held or
not".

Greg




More information about the Pyrex mailing list