[issue18835] Add aligned memory variants to the suite of PyMem functions/macros
STINNER Victor
report at bugs.python.org
Tue Oct 31 10:18:30 EDT 2017
STINNER Victor <victor.stinner at gmail.com> added the comment:
Nathaniel: "(...) and numpy won't necessarily use this API anyway."
Can you elaborate why numpy wouldn't use this new API? I designed it with numpy in mind :-)
Using PyMem_AlignedAlloc() instead of using directly posix_memalign()/_aligned_alloc() provides the debug features for free:
* tracemalloc is able to trace memory allocations
* detect buffer underflow
* detect buffer overflow
* detect API misuse like PyMem_Free(PyMem_AlignedAlloc()) -- it doesn't detect free(PyMem_AlignedAlloc()) which is plain wrong on Windows (but this one should crash immediately ;-))
Other advantages:
* PyMem_AlignedAlloc(alignment, 0) is well defined: it never returns NULL
* PyMem_AlignedAlloc(alignment, size) checks on alignment value are the same on all operating systems
Moreover, Python takes care of the portability for you :-)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue18835>
_______________________________________
More information about the Python-bugs-list
mailing list