I'm converting SWIG typemap'ed C extensions from numarray to numpy.
I studied (and use parts of) numpy.i from the doc directory.
I noticed that there is no
decref  for the  TYPEMAP_INPLACE2 typemap. This uses a function
obj_to_array_no_conversion() which in turn just returns
the original PyObject* ( casted to a PyArrayObject* after some sanity 
checks)  It looks to me that in this case there should be an explicit
Py_INCREF()  - in case the function is threaded (releases the Python 
GIL) since it holds a pointer to that object's data .

(Alternatively) Travis suggested (at the 
http://www.scipy.org/Converting_from_numarray wiki page) using
PyArray_FromAny  - is this incrementing the ref.count (implicitely) ? 
The numarray equivalent (NA_InputArray) IS incrementing the ref.count 
(as far as I know...).

Furthermore on that same wiki page the  PyArray_FromAny() is called 
together with PyArray_DescrFromType(<type>).
After searching through the numpy source I found that in
blasdot/_dotblas.c  (in dotblas_matrixproduct() )there is an explicit 
Py_INCREF even on the dtype returned from PyArray_DescrFromType.

I would argue that ref.counting is always very tricky territory ;-) 
Hopefully someone can enlighten me .

Sebastian Haase

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
Numpy-discussion mailing list

Reply via email to