import gc
#gc.set_debug(gc.DEBUG_LEAK)

class foo:
##    def __del__(self):
##        print 'foo del'
    pass

# This collects the cycle
print 'testing with dicts'
x = foo()
x.s = dict()
x.s[x] = True
del x
print gc.collect()
print gc.garbage

# This leaks a cycle
print 'testing with sets'
x = foo()
x.s = set()
x.s.add(x)
del x
print gc.collect()
print gc.garbage
