Re: keeping local state in an C extension module

2011-06-30 Thread Daniel Franke
2011/6/30 Stefan Behnel : >> If there are too many hoops to jump through to get a reasonable >> solution working for 2.[567], I might as well go back to >> Py_InitModule() and static variables. It's somewhat ugly, but it >> works. > > Py2.x has a PyCObject, basically the predecessor to PyCapsule. W

Re: keeping local state in an C extension module

2011-06-30 Thread Stefan Behnel
Daniel Franke, 30.06.2011 13:37: 2011/6/30 Stefan Behnel: There's a PEP for Py3 that enables this through a general framework. In general, to achieve this, you may want to allocate the module content (including types etc.) on the heap rather than statically. http://www.python.org/dev/peps/pep-3

Re: keeping local state in an C extension module

2011-06-30 Thread Thomas Rachel
Am 30.06.2011 12:07 schrieb Daniel Franke: Here, of course, the functions PyObjectFromRawPointer(void*) and void* PyRawPointerFromPyObject(PyObject*) are missing. Is there anything like this in the Python C-API? If not, how could it be implemented? You could implement it as a separate class wh

Re: keeping local state in an C extension module

2011-06-30 Thread Daniel Franke
Hi Stefan. 2011/6/30 Stefan Behnel : > Don't miss out taking a look at Cython, just in case it's going to be a > non-trivial project. I think this work still qualifies as trivial enough in this regard. But thanks for the hint! > There's a PEP for Py3 that enables this through a general framewor

Re: keeping local state in an C extension module

2011-06-30 Thread Stefan Behnel
Daniel Franke, 30.06.2011 12:07: For a project I implemented a extension module in C. Given the excellent documentation everything was straightforward and works fine so far. Don't miss out taking a look at Cython, just in case it's going to be a non-trivial project. Up until now I kept loc

keeping local state in an C extension module

2011-06-30 Thread Daniel Franke
Hi all. For a project I implemented a extension module in C. Given the excellent documentation everything was straightforward and works fine so far. Up until now I kept local state in global static variables, but would like to change this to pass a pointer to a state structure around. The Py_Init