Python's Memory Allocators: PyMem_* Family

Crucial for C extensions, `PyMem_Malloc`, `PyMem_Realloc`, and `PyMem_Free` ensure C-allocated memory is compatible with Python's memory manager, preventing corruption from mixing with standard `malloc`/`free` and enabling Python to track it.

Sources

Open the full topic