[Python-Dev] Garbage collecting closures (original) (raw)

Guido van Rossum guido@python.org
Fri, 11 Apr 2003 20:45:40 -0400


Does this bug look familiar to anyone?

import gc def bar(a): def foo(): return None x = a foo() class C:pass a = C() for i in range(20): print len(gc.getreferrers(a)) x = bar(a) On my Python, it just counts up. "a" gets more and more referrers and they are "cell" objects. If it is unknown, I'll submit a bug report unless someone fixes it before I get to it. ;)

If I use a "while 1" loop, the count never goes above 225.

--Guido van Rossum (home page: http://www.python.org/~guido/)