STINNER Victor <vstin...@python.org> added the comment:

I'm not sure that it's needed to have a "per interpreter" allocator. The needed 
feature is to be able to call PyMem_Malloc() in parallel in different threads. 
If I understood correctly, the glibc malloc has a per-thread fast allocator (no 
locking) and then falls back to a slow allocator (locking) if the fast 
allocator failed. Maybe pymalloc could have per-thread memory arenas.

When I implemented the PEP 587, I spend a significant amount of time to avoid 
using pymalloc before Py_Initialize() is called: only use PyMem_RawMalloc() 
before Py_Initialize().

But I'm not 100% sure that pymalloc is not used before Py_Initialize() nor 
*after* Py_Finalize(). For example, we should check if a daemon thread can call 
PyMem_Malloc() after Py_Finalize(), even if they are supposed to exit as soon 
as they try to acquire the GIL, even the GIL must be held to use pymalloc (to 
use PyMem_Malloc and PyObject_Malloc):
https://docs.python.org/dev/c-api/memory.html#memory-interface

See also bpo-37448:
"Add radix tree implementation for obmalloc address_in_range()"
https://github.com/python/cpython/pull/14474

----------

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

Reply via email to