[MATRIX-SIG] PyArrayObjects

Konrad Hinsen hinsen@ibs.ibs.fr
Fri, 8 Aug 1997 12:22:36 +0200


> Unfortunately, it seems to me that PyArray_ContiguousFromObject makes a copy of 
> the PyObject which I _must_ return to see my changes.  I would like my c functio
> n to simply access and modify the array data without making a copy.

Essentially there are two easy options and one complicated one:

1) Make a copy of the array and return the copy instead of modifying the
   original.
2) Restrict the function to contiguous arrays (and let it check its
   argument!).
3) Write some complicated code to modify an arbitrary array.

If the C function is supposed to be a general library routine, I
recommend the first solution; it's always messy to deal with functions
that modify a matrix. If, on the other hand, the C routine is just the
low-level work horse for an algorithm implemented mainly in Python,
the second solution may be better, and you might even know that the
array must be contiguous.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-4.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
_______________