A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2000-March/002478.html below:

call __del__ for cyclical garbage?

[Python-Dev] Design question: call __del__ for cyclical garbage?nascheme@enme.ucalgary.ca nascheme@enme.ucalgary.ca
Sun, 5 Mar 2000 17:27:54 -0700
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.


    Neil



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4