[Python-Dev] Class destructor

Nick Maclaren nmm1 at cus.cam.ac.uk
Fri Mar 2 10:53:21 CET 2007


Sorry about a second message, but I mentioned this aspect earlier,
and it is semi-independent.

If I want to produce statistics, such as the times spent in various
operations, I need a callback when the class is disposed of.  Now,
that WOULD be inconvenient to use the C object attribute callback,
unless I could be sure that would be called while the class structure
is still around.  That could be resolved by taking a copy, of course,
but that is messy.

This also relates to one of my problems with the callback.  I am not
being called back if the class is still live at program termination;
ones that have had their use counts drop to zero do cause a callback,
but not ones whose use count is above zero.  I am not sure whether
this is my error or a feature of the garbage collector.

If the latter, it doesn't matter from the point of view of freeing
space, but is assuredly a real pain for producing statistics.  I
haven't looked into it, as it is not an immediate task.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679


More information about the Python-Dev mailing list