show_refs.py
19 lines
| 355 B
| text/x-python
|
PythonLexer
Fernando Perez
|
r1403 | """Simple script to show reference holding behavior. | ||
This is used by a companion test case. | ||||
""" | ||||
import gc | ||||
class C(object): | ||||
Fernando Perez
|
r1910 | def __del__(self): | ||
pass | ||||
#print 'deleting object...' # dbg | ||||
Fernando Perez
|
r1403 | |||
Fernando Perez
|
r2109 | if __name__ == '__main__': | ||
c = C() | ||||
Fernando Perez
|
r1403 | |||
Fernando Perez
|
r2109 | c_refs = gc.get_referrers(c) | ||
Thomas Kluyver
|
r13379 | ref_ids = list(map(id,c_refs)) | ||
Fernando Perez
|
r1403 | |||
Thomas Kluyver
|
r13379 | print('c referrers:',list(map(type,c_refs))) | ||