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

Neil Schemenauer nas@python.ca
Tue, 6 Nov 2001 10:24:24 -0800


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 ?

PyMem_DEL should not be used since it could be using a different
allocator then PyObject_New.

> The reason I'm asking is that the mxDateTime objects I'm
> deallocating are actually unreferenced objects on a
> free list, so PyObject_Del() will probably bomb on them.

Why would it bomb?  It doesn't do anything special as far as I can tell
except free memory.  Vladimir went a bit overboard with the
pre-processor, IMHO, so its a little hard to tell for certain.

> Also, what should be done with failing constructors ? I usually
> use PyMem_DEL() to prevent the deallocator from being called but
> still free the allocated memory. Is that the correct approach ?

PyObject_Del() doesn't call the deallocator function.

  Neil