[Python-ideas] breaking cycles that include __del__
daniel at stutzbachenterprises.com
Tue Oct 20 18:58:36 CEST 2009
I'm playing around with this, and in following variant the weakref callback
is never called (in Python 2.6 and 3.1). I do not see why. I know I've
created a cycle between the callback and the object itself, but the garbage
collector should detect and free the cycle.
import weakref, gc
self._weakref = weakref.ref(self, self.__free__)
x = Foo()
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas