[docs] [issue32124] Document functions safe to be called before Py_Initialize()

STINNER Victor report at bugs.python.org
Fri Nov 24 11:05:00 EST 2017


STINNER Victor <victor.stinner at gmail.com> added the comment:

> Are you sure about PyMem_Malloc() and PyObject_Malloc()?

Technically, the pymalloc memory allocator is initialized statically by the compiler, from the first instruction of the process.

But maybe we should not suggest users to call them, especially because the allocator can be modified by the PYTHONMALLOC environment variable.

> What functions require them?

No function to initalize Python require PyMem or PyObject allocators. Only PyMem_Raw allocator is needed.

Py_EncodeLocale() uses it, but this function also uses Python objects (str, bytes), and so Py_EncodeLocale() must no be called before Py_Initialize().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32124>
_______________________________________


More information about the docs mailing list