Message305301
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 :-) |
|
Date |
User |
Action |
Args |
2017-10-31 14:18:30 | vstinner | set | recipients:
+ vstinner, tim.peters, rhettinger, pitrou, benjamin.peterson, trent, njs, skrah, neologix, xdegaye, wscullin |
2017-10-31 14:18:30 | vstinner | set | messageid: <1509459510.36.0.213398074469.issue18835@psf.upfronthosting.co.za> |
2017-10-31 14:18:30 | vstinner | link | issue18835 messages |
2017-10-31 14:18:30 | vstinner | create | |
|