Staging
v0.8.1
https://github.com/python/cpython
Raw File
Tip revision: cec00a7d87e7280b30eaef2e2567ebd0da5b8b9c authored by Ned Deily on 16 May 2016, 20:03:51 UTC
Version bump for 3.6.0a1
Tip revision: cec00a7
underlying_dict.py
import gc

thingy = object()
class A(object):
    def f(self):
        return 1
    x = thingy

r = gc.get_referrers(thingy)
if "__module__" in r[0]:
    dct = r[0]
else:
    dct = r[1]

a = A()
for i in range(10):
    a.f()
dct["f"] = lambda self: 2

print(a.f()) # should print 1
back to top