[Numpy-discussion] Request code review of numpy.i changes
Tue Mar 12 08:27:24 CDT 2013
I wasn't happy with my use of either PyCObject_FromVoidPtr or
PyArray_BASE. Both are now deprecated.
So I updated all the ARGOUTVIEWM_ definitions with
PyObject* cap = PyCapsule_New((void*)(*$1), SWIGPY_CAPSULE_NAME,
PyObject* cap = PyCObject_FromVoidPtr((void*)(*$1),
%#if NPY_API_VERSION < 0x00000007
PyArray_BASE(array) = cap;
This could probably be improved with the use of a macro, and checking
the returned value of PyArray_SetBaseObject wouldn't hurt either.
Anyway, it's a start. Hopefully I haven't messed my use of either
SWIGPY_CAPSULE_NAME or SWIG_Python_DestroyModule here.
Other changes I made relate to various warnings, in particular
relating to the use of SWIG_Python_AppendOutput($result, XXX) where
XXX should be a PyObject but was a PyArrayObject.
In ARGOUTVIEW / ARGOUTVIEWM typedefs, I made sure there was a
PyObject* obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE,
PyArrayObject* array = (PyArrayObject*) obj;
which allows me to then use (instead of ,array)
$result = SWIG_Python_AppendOutput($result,obj);
In the other few other instances where this construct doesn't apply
(ARGOUT_ARRAY1 for example) I used typecasting
$result = SWIG_Python_AppendOutput($result,(PyObject*)array$argnum);
I can't think of anything else at this stage.
On 12 March 2013 03:55, Bill Spotz <email@example.com> wrote:
> ** Bill Spotz **
> ** Sandia National Laboratories Voice: (505)845-0170 **
> ** P.O. Box 5800 Fax: (505)284-0154 **
> ** Albuquerque, NM 87185-0370 Email: firstname.lastname@example.org **
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 97351 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130312/c85b554b/attachment-0001.obj
More information about the NumPy-Discussion