[Python-Dev] RFC: PEP 445: Add new APIs to customize Python memory allocators

Victor Stinner victor.stinner at gmail.com
Tue Jun 18 23:20:04 CEST 2013

    typedef struct {
        /* user context passed as the first argument
           to the 2 functions */
        void *ctx;

        /* allocate a memory mapping */
        void* (*alloc) (void *ctx, size_t size);

        /* release a memory mapping */
        void (*free) (void *ctx, void *ptr, size_t size);
    } PyMemMappingAllocator;

The PyMemMappingAllocator structure is very specific to the pymalloc
allocator. There is no "resize", "lock" nor "protect" method. There is
no way to configure protection or flags of the mapping. The
PyMem_SetMappingAllocator() function was initially called
_PyObject_SetArenaAllocator(). I'm not sure that the structure and the
2 related functions should be public. Can an extension module call
private (_Py*) functions or use a private structure?

Or the structure might be renamed to indicate that it is specific to arenas?

What do you think?


More information about the Python-Dev mailing list