This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients benjamin.peterson, neologix, njs, pitrou, rhettinger, skrah, tim.peters, trent, vstinner, wscullin, xdegaye
Date 2017-10-31.14:18:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1509459510.36.0.213398074469.issue18835@psf.upfronthosting.co.za>
In-reply-to
Content
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 :-)
History
Date User Action Args
2017-10-31 14:18:30vstinnersetrecipients: + vstinner, tim.peters, rhettinger, pitrou, benjamin.peterson, trent, njs, skrah, neologix, xdegaye, wscullin
2017-10-31 14:18:30vstinnersetmessageid: <1509459510.36.0.213398074469.issue18835@psf.upfronthosting.co.za>
2017-10-31 14:18:30vstinnerlinkissue18835 messages
2017-10-31 14:18:30vstinnercreate