Staging
v0.8.1
https://github.com/python/cpython
Raw File
Tip revision: 3c6b436a57893dd1fae4e072768f41a199076252 authored by Ned Deily on 23 December 2018, 21:37:14 UTC
3.6.8final
Tip revision: 3c6b436
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