Discussion:
[Cython] gilnanny
mark florisson
2011-04-18 19:08:35 UTC
Permalink
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. While I'm at
it, I also want to add a pystate.pxd to the cpython includes.
Robert Bradshaw
2011-04-18 20:26:08 UTC
Permalink
On Mon, Apr 18, 2011 at 12:08 PM, mark florisson
Post by mark florisson
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.
Post by mark florisson
While I'm at it, I also want to add a pystate.pxd to the cpython includes.
Sure, corresponding to pystate.h? Have you looked into how stable this
API is (e.g. Py2 vs. Py3)?

- Robert
Sturla Molden
2011-04-18 22:18:51 UTC
Permalink
Post by Robert Bradshaw
On Mon, Apr 18, 2011 at 12:08 PM, mark florisson
Post by mark florisson
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
Stefan Behnel
2011-04-19 05:08:13 UTC
Permalink
Post by Sturla Molden
Post by Robert Bradshaw
Post by mark florisson
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?
Yes, that's what this is all about.

https://github.com/markflorisson88/cython/commits/master

Stefan
Sturla Molden
2011-04-19 19:49:56 UTC
Permalink
Post by Stefan Behnel
Yes, that's what this is all about.
https://github.com/markflorisson88/cython/commits/master
Great :)

Sturla

mark florisson
2011-04-19 07:09:53 UTC
Permalink
Post by Robert Bradshaw
On Mon, Apr 18, 2011 at 12:08 PM, mark florisson
Post by mark florisson
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.
Ok, cool :)
Post by Robert Bradshaw
Post by mark florisson
While I'm at it, I also want to add a pystate.pxd to the cpython includes.
Sure, corresponding to pystate.h? Have you looked into how stable this
API is (e.g. Py2 vs. Py3)?
I haven't looked at all the functions, but most of them are documented
in both Python 2 and Python 3. I'll be vigilant.
Post by Robert Bradshaw
- Robert
_______________________________________________
cython-devel mailing list
http://mail.python.org/mailman/listinfo/cython-devel
Loading...