gc questions

Moshe Zadka m at moshez.org
Wed Jun 18 09:52:58 EDT 2003


On Wed, 18 Jun 2003, "Edward K. Ream" <edreamleo at charter.net> wrote:

> 1.  The gc documentation says: " This module...provides access to
> unreachable objects that the collector found but cannot free."  I thought
> the gc could free cycles.  Why would the gc be unable to free objects that
> are, in fact, no longer being used?

__del__-full cycles.

class a:
    def __del__(self): print self.f
t, s = a(), a()
t.f = s
s.f = t
del s t

Now, who should have his __del__ called first, s or t?
And what will "print self.f" do, when it tries to print a deleted
object? segfault?

-- 
Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/





More information about the Python-list mailing list