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

M.-A. Lemburg mal@lemburg.com
Mon, 06 Mar 2000 11:01:31 +0100


nascheme@enme.ucalgary.ca wrote:
> 
> On Fri, Mar 03, 2000 at 08:38:43PM -0500, Tim Peters wrote:
> > So here's what I'd consider doing:  explicit is better than implicit, and in
> > the face of ambiguity refuse the temptation to guess.
> 
> I like Marc's suggestion.  Here is my proposal:
> 
> Allow classes to have a new method, __cleanup__ or whatever you
> want to call it.  When tp_clear is called for an instance, it
> checks for this method.  If it exists, call it, otherwise delete
> the container objects from the instance's dictionary.  When
> collecting cycles, call tp_clear for instances first.
> 
> Its simple and allows the programmer to cleanly break cycles if
> they insist on creating them and using __del__ methods.

Right :-)

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/