On Thursday 02 January 2003 03:47 pm, François Pinard wrote:
Because garbage cycles can point at non-garbage; when the garbage is reclaimed, __del__() methods will run.
When cycles contain `__del__()', they are wholly added to gc.garbage if I understand the documentation correctly, and so, `__del__()' will not be run.
Yes, but that doesn't affect Aahz's argument -- consider, e.g.:
class Nodel: pass class Hasdel: def __del__(self): print 'del(%s)'%self a, b, c = Nodel(), Nodel(), Nodel() a.x = b; b.x = c; c.x = a b.y = Hasdel() del a, b, c import gc # gc.collect()
Here, the __del__ method is never run, but, if you uncomment the gc.collect call, then the __del__ method IS run -- just as Aahz said.