Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: c1004b85464579771db3b50f5b150449275bbbd0 authored by Ɓukasz Langa on 06 May 2019, 18:30:25 UTC
Python 3.8.0a4
Tip revision: c1004b8
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