[PYTHON MATRIX-SIG] Create and fill an array from Numeric module in C function ??
VIENNET Emmanuel 48.06.27.97 Equipe Gallinari
Emmanuel.Viennet@laforia.ibp.fr
Fri, 14 Jun 1996 18:15:57 +0200
Jean-Louis Villecroze writes:
> Hello,
>
> I'm currently working in the integration of a library in Python, and i
> would like to create and fill a Numeric array from my Data but directly
> in a C function, which be used in Python ...
>
Quite easy :-)
write a python-C glue function:
- to create a new array and return it:
int dims[ nbdims ] = { ... };
arr = (PyArrayObject *)PyArray_FromDims( nbdims, dims, PyArray_FLOAT );
use the memory pointed by arr->data
When you're done, return a python object:
return (PyObject *)arr;
For more infos, look at Include/arrayobject.h, where you will find
usefull comments.
Have fun
Emmanuel
--
Emmanuel Viennet: <viennet@ura1507.univ-paris13.fr>
LIPN - Institut Galilee - Universite Paris-Nord
93430 Villetaneuse - France
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================