Closed
Description
There are two uses for PyMem_SetAllocator()
:
- set the allocator for the runtime to use
- set an allocator hook that wraps the current allocator
The first must be done (only by embedders) "just after the pre-initialization, and before the Python initialization", while the second may be done at any point (e.g. by extension modules, like tracemalloc). See #96975 (comment).
The docs for PyMem_SetAllocator()
should make the distinction more clear, as well as identifying the restriction on (1).