Commit ecf1fda8 authored by mattip's avatar mattip

MAINT: avoid numpy internals in {sg}et_array_base

parent ad6493a4
...@@ -71,6 +71,8 @@ Other changes ...@@ -71,6 +71,8 @@ Other changes
package size to about half of its previous size. This makes the compiler package size to about half of its previous size. This makes the compiler
slightly slower, by about 5-7%. slightly slower, by about 5-7%.
* ``set_array_base`` now calls ``PyArray_SetBaseObject``. Also modified
``get_array_base`` to remove direct access to NumPy internals.
0.28.4 (2018-07-08) 0.28.4 (2018-07-08)
=================== ===================
......
...@@ -719,6 +719,7 @@ cdef extern from "numpy/arrayobject.h": ...@@ -719,6 +719,7 @@ cdef extern from "numpy/arrayobject.h":
object PyArray_CheckAxis (ndarray, int *, int) object PyArray_CheckAxis (ndarray, int *, int)
npy_intp PyArray_OverflowMultiplyList (npy_intp *, int) npy_intp PyArray_OverflowMultiplyList (npy_intp *, int)
int PyArray_CompareString (char *, char *, size_t) int PyArray_CompareString (char *, char *, size_t)
int PyArray_SetBaseObject(object, object)
# Typedefs that matches the runtime dtype objects in # Typedefs that matches the runtime dtype objects in
...@@ -973,22 +974,12 @@ cdef extern from "numpy/ufuncobject.h": ...@@ -973,22 +974,12 @@ cdef extern from "numpy/ufuncobject.h":
int _import_umath() except -1 int _import_umath() except -1
cdef inline void set_array_base(object arr, object base):
Py_INCREF(base)
PyArray_SetBaseObject(arr, base)
cdef inline void set_array_base(ndarray arr, object base): cdef inline object get_array_base(object arr):
cdef PyObject* baseptr return <object>arr.base
if base is None:
baseptr = NULL
else:
Py_INCREF(base) # important to do this before decref below!
baseptr = <PyObject*>base
Py_XDECREF(arr.base)
arr.base = baseptr
cdef inline object get_array_base(ndarray arr):
if arr.base is NULL:
return None
else:
return <object>arr.base
# Versions of the import_* functions which are more suitable for # Versions of the import_* functions which are more suitable for
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment