Python method reference kills garbage collection?

Troels Walsted Hansen troels at fast.no
Thu Feb 7 06:03:57 EST 2002


Consider the following program. What is so special about references to the
object's own methods that cause the object to never be garbage collected? Is
this a cyclic reference problem, and if so why doesn't the cycle detector
(--with-cycle-gc) cure the problem?

class a:
    def __init__(self):
        self.f = self.f1
    def __del__(self):
        print "this is never printed"
    def f1(self):
        pass
b=a()
b=a()

--
Troels Walsted Hansen M.Eng.       Mail:  troels at fast.no
Software Engineer                  Web:   http://www.fast.no/
Fast Search & Transfer ASA

Try FAST Search: http://alltheweb.com






More information about the Python-list mailing list