Destructor never called ???

Alex Martelli aleax at aleax.it
Fri Sep 20 15:00:37 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?

These are not mutually exclusive, and they all look good to me.  If
you can avoid __del__, do; if you can avoid reference loops (e.g thanks
to weak references) do that, too.  And checking that some leak didn't
happen anyway is sound.


Alex




More information about the Python-list mailing list