Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: But the garbage collector was invented for this very purpose: to break cycles! Take the following example which create a cycle for every instance of the class (the profile module has similar code):
class C: def __init__(self): self.action = self.action_GO # cycle: the object's dict now contains a bound method # which references the object def action_GO(self): print("GO") This kind of construct is useful, and probably the best one in some cases. Would you ban it from your code? from the python standard library? Reference cycles are not bad at all, as long as they only hold memory: they will be reclaimed when the systems needs more memory. I agree that they can be a problem for other valuable resource: opened files, sockets, database cursors... even one thousand of uncollected sockets are not enough to trigger a collection. For this usage, I suggest that you iterate over gc.garbage, only warn for such objects and remove all others (and after, clear gc.garbage and run gc.collect() without the debug flag) _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4273> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com