[PYTHON MATRIX-SIG] C API questions
Konrad Hinsen
hinsen@ibs.ibs.fr
Tue, 5 Nov 96 18:52:29 +0100
> > 1) How should I construct the array object to make sure that Python
> > will not try to allocate or free memory for the actual data?
>
> I am using PyArray_FromDimsAndData. If data is passed into this function,
> then the flag OWN_DATA is not set. In array_dealloc, if OWN_DATA is not
> set, then the data pointer of the array object is not freed.
Seeme easy enough...
> I decrement the reference to the array object after the python function
> call. I do not increment it before the function call. The array
Yes, of course. It starts out at one, as for any newly created object.
> I have not done this, but I should. Checking the reference count and
> raising an exception should work in most cases.
It surely beats a crash due to an access to unallocated memory!
Thanks for your comments, it seems clear now what I have to do.
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-76.88.99.28
Institut de Biologie Structurale | Fax: +33-76.88.54.94
41, av. des Martyrs | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France | Nederlands/Francais
-------------------------------------------------------------------------------
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================