2 ms·
The reference implementation (CPython) does use reference counting, but that is not its only approach to garbage collection. "The default build implementation
by foresto 3y ago
The reference implementation (CPython) does use reference counting, but that is not its only approach to garbage collection.
"The default build implementation is a generational collector. The free-threaded build is non-generational; each collection scans the entire heap."
https://devguide.python.org/internals/garbage-collector/ https://devguide.python.org/internals/garbage-collector/
https://docs.python.org/3/library/gc.html https://docs.python.org/3/library/gc.html
(And as someone else pointed out, asyncio's event loop keeps only weak references to tasks, so the GC implementation doesn't really matter here.)