Resolve circular reference

Magnus Lyckå lycka at carmen.se
Thu Jan 13 13:12:49 EST 2011


On 2011-01-07 03:24, moerchendiser2k3 wrote:
> Everything works fine, the problem starts when I start to make a
> circular reference in Python.

I didn't quite grok your example, but concerning CPython GC & circular 
references...

 >>> import gc
 >>> class X:
...     def __del__(self):
...             print 'Deleted', self
...
 >>> a = X()
 >>> del a
Deleted <__main__.X instance at 0x00CCCF80>
 >>> a=X()
 >>> b=X()
 >>> a.b=b
 >>> b.a=a
 >>> del a
 >>> gc.collect()
0
 >>> del b
 >>> gc.collect()
4
 >>>



More information about the Python-list mailing list