[Python-Dev] cpython: Issue #3329: Add new APIs to customize memory allocators (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Sat Jun 15 13:01:25 CEST 2013
- Previous message: [Python-Dev] cpython: Issue #3329: Add new APIs to customize memory allocators
- Next message: [Python-Dev] cpython: Issue #3329: Add new APIs to customize memory allocators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, 15 Jun 2013 03:54:50 +0200 Victor Stinner <victor.stinner at gmail.com> wrote:
The addition of PyMemRawMalloc() is motivated by the issue #18203 (Replace calls to malloc() with PyMemMalloc()). The goal is to be able to setup a custom allocator for all allocation made by Python, so malloc() should not be called directly. PyMemRawMalloc() is required in places where the GIL is not held (ex: in os.getcwd() on Windows).
We already had this discussion on IRC and this argument isn't very convincing to me. If os.getcwd() doesn't hold the GIL while allocating memory, then you should fix it to hold the GIL while allocating memory.
I don't like the idea of adding of third layer of allocation APIs. The dichotomy between PyObject_Malloc and PyMem_Malloc is already a bit gratuitous (i.e. not motivated by any actual real-world concern, as far as I can tell).
As for the debug functions you added: PyMem_GetRawAllocators(), PyMem_SetRawAllocators(), PyMem_GetAllocators(), PyMem_SetAllocators(), PyMem_SetupDebugHooks(), _PyObject_GetArenaAllocators(), _PyObject_SetArenaAllocators(). Well, do we need all 7 of them? Can't you try to make that 2 or 3?
Regards
Antoine.
- Previous message: [Python-Dev] cpython: Issue #3329: Add new APIs to customize memory allocators
- Next message: [Python-Dev] cpython: Issue #3329: Add new APIs to customize memory allocators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]