show_refs.py 393 B

1234567891011121314151617181920
  1. """Simple script to show reference holding behavior.
  2. This is used by a companion test case.
  3. """
  4. from __future__ import print_function
  5. import gc
  6. class C(object):
  7. def __del__(self):
  8. pass
  9. #print 'deleting object...' # dbg
  10. if __name__ == '__main__':
  11. c = C()
  12. c_refs = gc.get_referrers(c)
  13. ref_ids = list(map(id,c_refs))
  14. print('c referrers:',list(map(type,c_refs)))