[Cython] gilnanny
Sturla Molden
sturla at molden.no
Tue Apr 19 00:18:51 CEST 2011
Den 18.04.2011 22:26, skrev Robert Bradshaw:
> On Mon, Apr 18, 2011 at 12:08 PM, mark florisson
> <markflorisson88 at gmail.com> wrote:
>> Can I add a gilnanny to refnanny? I want to do a PyThreadState_Get()
>> for every refnanny inc- and decref, so that it will issue a fatal
>> error whenever reference counting is done without the gil, to make
>> sure we never do any illegal things in nogil code blocks.
> Sounds like a good idea to me.
>
Have you ever considered to allow a "with gil:" statement? It seems this
could be implemented using the simplified GIL API, i.e. the same way
ctypes synchronizes callbacks to Python. Usecases would e.g. be
computational code that sometimes needs to touch Python objects. E.g.
append something to a list, slice a NumPy array, unbox a buffer into
local scope, etc. A "with gil" statement could allow us to grab the GIL
back for that.
Sturla
More information about the cython-devel
mailing list