1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | class Foo:
def __del__(self):
print('freed', self)
def make():
for i in range(2):
yield Foo()
from sys import getrefcount as rc
for obj in make():
# refcount should == 2, one for `obj` binding and other for the argument
# binding in rc().
print(rc(obj))
del obj
|