You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

py-ref-count.py 302 B

12345678910
  1. import sys
  2. a = [1, 2, 3]
  3. print(f"a's reference count: {sys.getrefcount(a)}")
  4. b = a
  5. print(f"a's reference count: {sys.getrefcount(a)}")
  6. print(f"b's reference count: {sys.getrefcount(b)}")
  7. del b
  8. print(f"a's reference count: {sys.getrefcount(a)}")
  9. del a
  10. print(f"a's reference count: {sys.getrefcount(a)}")