Destructor never called ???

Greg Ewing see_reply_address at something.invalid
Sun Sep 22 20:49:19 EDT 2002

Thomas Heller wrote:

> So what are the recommended practices if my program creates datastructures
> containing cyclic references?
> - avoid using __del__ in these objects by  cleaning them 'manually'?
> - only using weak references to break these cycles?
> - and finally using the debugflags of the gc module to ensure everything
> is cleaned correctly?

If you really must have __del__ methods in cyclic
data structures, you could examine the uncollectable-
garbage list periodically and do something to break
up the cycles. Once you've manually broken the
cycle, normal refcounting will take care of the
rest and the __del__s will be called.

Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand

More information about the Python-list mailing list