[Numpy-discussion] quick C api array creation question
Charles سمير Doutriaux
doutriaux1 at llnl.gov
Wed Jul 15 19:58:56 EDT 2009
I think i can answer my own question
I need to return Py_BuildValue("(NNN)")
C.
On Jul 15, 2009, at 4:27 PM, Charles سمير Doutriaux wrote:
> Hi,
>
> I'm using a C api to create numpy array
>
> I create them in my C as follow:
>
> np_ow = (PyArrayObject *)PyArray_SimpleNew(4, dims, NPY_DOUBLE);
> np_osfc = (PyArrayObject *)PyArray_SimpleNew(3, dims, NPY_DOUBLE);
> np_ospc = (PyArrayObject *)PyArray_SimpleNew(3, dims, NPY_DOUBLE);
> PyArray_FILLWBYTE(np_ow,0);
> PyArray_FILLWBYTE(np_osfc,0);
> PyArray_FILLWBYTE(np_ospc,0);
> ...
> return Py_BuildValue("OOO",np_ow,np_osfc,np_ospc);
>
> It seems to work and they get back nicely to the python, no problem
>
> The only "little" issue I have is that the memory is never released!
> And quickly my code runs out of memory
>
> Any pointer on what I'm doing wrong?
>
> Do I need a decref somewhere?
>
> C.
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://*mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list