Skip to content

[C-API Docs] Clarify About When PyMem_SetAllocator() Can Be Called #96997

Closed
@ericsnowcurrently

Description

@ericsnowcurrently

There are two uses for PyMem_SetAllocator():

  1. set the allocator for the runtime to use
  2. 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).

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dir

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions