STINNER Victor <victor.stin...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue18835>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to