[Python-Dev] Design question: call __del__ for cyclical garbage?

Skip Montanaro skip@mojam.com (Skip Montanaro)
Sun, 5 Mar 2000 10:42:30 -0600 (CST)


    Guido> What keeps nagging me though is what to do when there's a
    Guido> finalizer but no cleanup method.  I guess the trash cycle remains
    Guido> alive.  Is this acceptable?  (I guess so, because we've given the
    Guido> programmer a way to resolve the trash: provide a cleanup method.)

That assumes the programmer even knows there's a cycle, right?  I'd like to
see this scheme help provide debugging assistance.  If a cycle is discovered
but the programmer hasn't declared a cleanup method for the object it wants
to cleanup, a default cleanup method is called if it exists
(e.g. sys.default_cleanup), which would serve mostly as an alert (print
magic hex values to stderr, popup a Tk bomb dialog, raise the blue screen of
death, ...) as opposed to actually breaking any cycles.  Presumably the
programmer would define sys.default_cleanup during development and leave it
undefined during production.

Skip Montanaro | http://www.mojam.com/
skip@mojam.com | http://www.musi-cal.com/