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

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 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

defining class and subclass in C

2012-01-14 Thread Daniel Franke
Hi all. I spent some days and nights on this already and my google-fu is running out. I'd like to implement the equivalent of this Python code in a C-extension: >>> class A(object): ... pass >>> class B(A): ... pass >>> A >>> B >>> B.__bases__ (,) However, loading my C-code (quoted below)

Re: defining class and subclass in C

2012-01-14 Thread Daniel Franke
On Saturday 14 January 2012 22:15:36 Daniel Franke wrote: > Here I'd expect "" instead?! And I never managed a proper > subclass :| Found an explanation on type/class at [1]: "he difference between the two is whether the C-level type instance structure is flagged as hav

building foo.pyd, _initfoo vs. initfoo

2012-01-22 Thread Daniel Franke
Hi all. Usually I work on Linux and all my cmake-built Python extensions working there without trouble. Now these things need to work on Windows as well. While the code itself compiles fine, linking and loading makes trouble. First of, to successfully link everything with mingw (g++-4.4.0, som