STINNER Victor added the comment: In february 2016, I started a thread on the python-dev mailing list: [Python-Dev] Modify PyMem_Malloc to use pymalloc for performance https://mail.python.org/pipermail/python-dev/2016-February/143084.html
M.-A. Lemburg wrote: """ > Do you see any drawback of using pymalloc for PyMem_Malloc()? Yes: You cannot free memory allocated using pymalloc with the standard C lib free(). It would be better to go through the list of PyMem_*() calls in Python and replace them with PyObject_*() calls, where possible. > Does anyone recall the rationale to have two families to memory allocators? The PyMem_*() APIs were needed to have a cross-platform malloc() implementation which returns standard C lib free()able memory, but also behaves well when passing 0 as size. """ M.-A. Lemburg fears that the PyMem_Malloc() API is misused: """ Sometimes, yes, but we also do allocations for e.g. parsing values in Python argument tuples (e.g. using "es" or "et"): https://docs.python.org/3.6/c-api/arg.html We do document to use PyMem_Free() on those; not sure whether everyone does this though. """ M.-A. Lemburg suggested to the patch of this issue on: """ Yes, but those are part of the stdlib. You'd need to check a few C extensions which are not tested as part of the stdlib, e.g. numpy, scipy, lxml, pillow, etc. (esp. ones which implement custom types in C since these will often need the memory management APIs). It may also be a good idea to check wrapper generators such as cython, swig, cffi, etc. """ ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26249> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com