Back to search

How does Python garbage collection work?

Python primarily uses reference counting, with cyclic garbage collection to clean objects that reference each other.

Python Medium Theory

How does Python garbage collection work?

Python primarily uses reference counting, with cyclic garbage collection to clean objects that reference each other.

  • Reference count frees many objects immediately
  • Cycles need GC pass
  • Del methods can complicate cleanup

How does Python garbage collection work?