[Pyrex] Structures containing pointers to Python objects

Konrad Hinsen hinsen at cnrs-orleans.fr
Mon Feb 2 10:39:59 CET 2004


On Monday 02 February 2004 02:04, Greg Ewing wrote:

> You can't. You've declared Numeric.ArrayType as a Python type, and
> Pyrex won't let you put references to Python objects in a struct
> (because it wouldn't be able to manage the reference counting
> properly).

I don't expect it to, the reference should be considered a borrowed one.

> If you can tell me more about why you need to do this, I may
> be able to suggest a workaround.

I have a bit of nontrivial code that works on information stored in Python 
arrays. There is only one entry point from the Python universe, which takes 
care of reference counting. Then it puts pointers to various arrays into a 
few structures which are passed on to a lot of C subroutines. They all return 
before control is passed back to Python.

The list of C subroutines to be called is dynamic, and I want to write 
additional plugins in Pyrex, which is why I need to pass in a pointer to a 
struct which contains a pointer to a Python object.

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------





More information about the Pyrex mailing list