[Numpy-discussion] Memory allocation cleanup

Charles R Harris charlesr.harris at gmail.com
Thu Jan 9 18:21:17 EST 2014


Apropos Julian's changes <https://github.com/numpy/numpy/pull/4177> to use
the PyObject_* allocation suite for some parts of numpy, I posted the
following

I think numpy memory management is due a cleanup. Currently we have

PyDataMem_*
PyDimMem_*
PyArray_*

Plus the malloc, PyMem_*, and PyObject_* interfaces. That is six ways to
manage heap allocations. As far as I can tell, PyArray_* is always
PyMem_*in practice. We probably need to keep the
PyDataMem family as it has a memory tracking option, but PyDimMem just
confuses things, I'd rather just use PyMem_* with explicit size. Curiously,
the PyObject_Malloc family is not documented apart from some release notes.

We should also check for the macro versions of PyMem_* as they are
deprecated for extension modules.
 Nathaniel then suggested that we consider going all Python allocators,
especially as new memory tracing tools are coming online in 3.4. Given that
these changes could have some impact on current extension writers I thought
I'd bring this up on the list to gather opinions.

Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140109/d1fd200a/attachment.html>


More information about the NumPy-Discussion mailing list