M.-A. Lemburg schrieb am 04.02.2016 um 13:54:
On 04.02.2016 13:29, Victor Stinner wrote:
But, why not PyObject_Malloc() & PObject_Free() were not used in the first place?
Good question. I guess developers simply thought of PyObject_Malloc() being for PyObjects, not arbitrary memory buffers, most likely because pymalloc was advertised as allocator for Python objects, not random chunks of memory.
Note that the PyObject_Malloc() functions have never been documented. (Well, there are references regarding their mere existence in the docs, but nothing more than that.)
And, for example, the "what's new in 2.5" document says:
""" Python’s API has many different functions for allocating memory that are grouped into families. For example, PyMem_Malloc(), PyMem_Realloc(), and PyMem_Free() are one family that allocates raw memory, while PyObject_Malloc(), PyObject_Realloc(), and PyObject_Free() are another family that’s supposed to be used for creating Python objects. """
I don't think there are many extensions out there in which *object* memory gets allocated manually, which implicitly puts a pretty clear "don't use" marker on these functions.