On Mon, Nov 20, 2017 at 3:03 PM, Victor Stinner <victor.stin...@gmail.com> wrote: > To statically initialize PyMemAllocatorEx fields, you need to export a > lot of allocator functions. I would prefer to not do that. > > [snip] > > The rules to choose the allocator to each domain are also complex > depending if pymalloc is enabled, debug hooks are enabled by default, > etc. The memory allocator is also linked to _PyMem_Debug which is not > currently in Include/internals/ but Objects/obmalloc.c.
I'm not suggesting supporting the full machinery. Rather, as my PR demonstrates, we can statically initialize the minimum needed to support pre-init use of PyMem_RawMalloc() and PyMem_RawFree(). The allocators will be fully initialized once the runtime is initialized (i.e. once Py_Initialize() is called), just as they are now. FWIW, I'm not sure that's the best approach. See my notes in https://bugs.python.org/issue32096. > > I understand that moving global variables to _PyRuntime helps to > clarify how these variables are initialized and then finalized, but > memory allocators are a complex corner case. Agreed. I spent a large portion of my time getting the allocators right when working on the original _PyRuntime patch. It's tricky code. -eric _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com