STINNER Victor added the comment:

"Victor, I was thinking of switching to PyMem_RawMalloc instead of 
PyMem_Malloc.  The advantages are that there are guaranteed to be no 
side-effects, the GIL doesn't need to be held, and there is less overhead.  Are 
there any disadvantage I should know about?"

For me, PyMem_Malloc() can be faster than PyMem_RawMalloc() because the GIL is 
held. In practice... both function are very thin wrapper to malloc(), so it's 
exactly the same :-) In Objects/obmalloc.c, you have:

#define PYRAW_FUNCS _PyMem_RawMalloc, _PyMem_RawCalloc, _PyMem_RawRealloc, 
_PyMem_RawFree
...
#define PYMEM_FUNCS PYRAW_FUNCS

So PyMem_Malloc() and PyMem_RawMalloc() are *currently* exactly the same.

I'm not sure that you understand what you are trying to do. If you expect 
better performances, you should try to use PyObject_Malloc() instead, to 
benefit from the fast Python allocator for small allocations (512 bytes and 
less).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25135>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to