0

trying to figure out when garbage collector collects and what it collects,

import gc
a = 1
print(gc.get_count())
a = 2
print(gc.get_count())
a = 3
print(gc.get_count())
gc.collect()
print(gc.get_count())
print(a)

output:

(101, 5, 3)
(128, 5, 3)
(128, 5, 3)
(0, 0, 0)
3

why it prints a after (0, 0, 0)? from what i understood it cleans reference cycles only, if it is why do i get (0, 0, 0)? variable a need to promoted to second level?

Ori
  • 67
  • 5

0 Answers0