Interest in generational GC for Python

"Martin v. Löwis" martin at v.loewis.de
Mon Apr 20 15:56:04 EDT 2009


> I'm lost there. Isn't CPython using reference counting (i.e updating the
> object's state at each reference creation/deletion, and deleting the
> objects as soon as they have no more references to them) ? It seemed to
> me that generational GC only applied to periodic GCs, like tracing
> garbage collectors. Or is CPython using a mix of both technologies (to
> prevent cycles for example) ?

The latter, since Python 2.2. See Modules/gcmodule.c for implementation
details.

It can't really prevent cycles, but it can collect them once they become
garbage (and the garbage collector is triggered, in the right
generation). Objects not participating in cycles are released
immediately when they become unreachable.

Regards,
Martin



More information about the Python-list mailing list