[Python-Dev] RE: Program very slow to finish

Tim Peters tim.one@home.com
Tue, 6 Nov 2001 18:07:56 -0500


[M.-A. Lemburg wrote:]
> What is considered the "right" approach for this ? Should Python
> objects *always* be deallocated using one of PyObject_Del() and
> PyObject_DEL() or is PyMem_DEL() usable as well ?

I agree with everything Neil said.  Note that the xxx_del/DEL functions are
not destructors, nor do they call destructors.  Despite their arguably odd
names, they don't even care whether you pass a pointer to a Python object.
Without pymalloc enabled, chase down the layers of macros and all any of
them do is call free(), although PyMem_DEL -> PyMem_FREE -> PyCore_FREE ->
PyCore_FREE_FUNC and there's *some* scheme or other hiding in here that's
supposed to let users define their own expansion for at least one of the
steps in that chain.  It's complicated, and I'm not sure anyone understands
all the design details anymore.