[Greg Ewing] > However, if they're not exclusively for objects, > having "Object" in the name would seem to be > highly confusing, perhaps dangerously so. (Person > A writes PyObject_Alloc(some_chars), Person B > writing the code to free it thinks "What??? > That can't be right!" and uses PyMem_Free.)
Given that it's been this way since the PyObject_ memory family was introduced, and a real Person B hasn't posted to complain about being led into temptation yet, sorry, I don't take this argument seriously. The comments in objimpl.h tell the truth, and it's really quite simple: For allocating objects, use PyObject_{New, NewVar} instead whenever possible. The PyObject_{Malloc, Realloc, Free} family is exposed so that you can exploit Python's small-block allocator for non-object uses. If you must use these routines to allocate object memory, make sure the object gets initialized via PyObject_{Init, InitVar} after obtaining the raw memory. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com