Hacker News new | past | comments | ask | show | jobs | submit login

Get garbage collected by what? Doesn’t Python use reference counting?



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://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.)


asyncio doesn't store strong references to tasks. It is your responsibility to keep the ref: https://docs.python.org/3/library/asyncio-task.html#asyncio....

Consider organizing the code using TaskGroup.


Python has a GC.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: