[Numpy-discussion] libnpysort.a and PyDataMem_NEW/FREE

Thouis (Ray) Jones thouis at gmail.com
Wed May 23 11:37:54 EDT 2012

The "private" libnpysort.a (see https://github.com/numpy/numpy/pull/89
for its history) uses PyDataMem_NEW/FREE.  I'm trying to convert these
to actual functions to allow tracing numpy memory allocations (see

However, these new functions have to be in the API to allow
third-party extensions to use them.  This prevents libnpysort.a from
finding them, as adding NUMPY_API to the declaration makes them static
during the build process.

There are several ways this could be dealt with:
- convert all the NEW/FREE calls in the sort library to malloc/free
(or the Python memory equivalents)
- create a separate library for the memory functions (like
libnpysort.a), but linked earlier.
- something else?

I'm not familiar enough with the internal of numpy and its API to know
which is the best approach.  Since the sorting functions could
allocate significant amounts of data, I think it would be best for
allocations within them to be tracable.

Ray Jones

More information about the NumPy-Discussion mailing list