From: Todd M. <jm...@st...> - 2004-02-25 17:35:41
|
On Wed, 2004-02-25 at 11:34, Marco Bubke wrote: > Ok > > cdef NumArray array_to_float(NumArray array): > cdef NumArray new_array > new_array = array > NA_updateDataPtr(new_array) > NA_updateDataPtr(new_array) > flat_array = NA_InputArray(array, tFloat32, NUM_C_ARRAY) > return flat_array > > Here the C code: > > static PyArrayObject *__pyx_f_2gl_array_to_float(PyArrayObject *__pyx_v_array) > { > PyArrayObject *__pyx_v_new_array; > PyObject *__pyx_v_flat_array; > PyArrayObject *__pyx_r; > PyObject *__pyx_1 = 0; > Py_INCREF(__pyx_v_array); > ((PyObject*)__pyx_v_new_array) = Py_None; > Py_INCREF(((PyObject*)__pyx_v_new_array)); > __pyx_v_flat_array = Py_None; Py_INCREF(__pyx_v_flat_array); > > /* "/home/marco/projects/calliopeia/numarray.pxd":102 */ > Py_INCREF(((PyObject *)__pyx_v_array)); > Py_DECREF(((PyObject *)__pyx_v_new_array)); > ((PyObject *)__pyx_v_new_array) = ((PyObject *)__pyx_v_array); > > /* "/home/marco/projects/calliopeia/numarray.pxd":103 */ > __pyx_1 = NA_updateDataPtr(((PyObject *)__pyx_v_new_array)); if (!__pyx_1) > {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L > 1;} > Py_DECREF(__pyx_1); __pyx_1 = 0; One problem is right here: NA_updateDataPtr does not return a new reference. Thus, _pyx_v_new_array/_pyx_1 is losing references right here. > > /* "/home/marco/projects/calliopeia/numarray.pxd":104 */ > __pyx_1 = NA_updateDataPtr(((PyObject *)__pyx_v_new_array)); if (!__pyx_1) > {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L > 1;} > Py_DECREF(__pyx_1); __pyx_1 = 0; And of course it's also losing them here as well. I haven't finished analyzing the rest of the code. If that fix doesn't solve the problem, let me know. Regards, Todd > > /* "/home/marco/projects/calliopeia/numarray.pxd":105 */ > __pyx_1 = NA_InputArray(((PyObject *)__pyx_v_array),tFloat32,NUM_C_ARRAY); > if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105 > ; goto __pyx_L1;} > Py_DECREF(__pyx_v_flat_array); > __pyx_v_flat_array = __pyx_1; > __pyx_1 = 0; > > /* "/home/marco/projects/calliopeia/numarray.pxd":106 */ > if (!__Pyx_TypeTest(__pyx_v_flat_array, __pyx_ptype_2gl__numarray)) > {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} > Py_INCREF(__pyx_v_flat_array); > __pyx_r = (PyArrayObject *)__pyx_v_flat_array; > goto __pyx_L0; > > (PyObject *)__pyx_r = Py_None; Py_INCREF((PyObject *)__pyx_r); > goto __pyx_L0; > __pyx_L1:; > Py_XDECREF(__pyx_1); > __Pyx_AddTraceback("gl.array_to_float"); > __pyx_r = 0; > __pyx_L0:; > Py_DECREF(__pyx_v_new_array); > Py_DECREF(__pyx_v_flat_array); > Py_DECREF(__pyx_v_array); > return ((PyArrayObject *)__pyx_r) ; > } > > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion -- Todd Miller <jm...@st...> |