Tim Peters <t...@python.org> added the comment:
It's impossible for any implementation to know that cyclic trash _is_ trash without, in some way, traversing the object graph. This is expensive, so CPython (or any other language) does not incur that expense after every single decref that leaves a non-zero refcount (the one and only cheap clue that cyclic trash _may_ have just been created). If you want/need synchronous behavior, avoid cycles. CPython's refcounting does dispose of trash the instant an object (not involved in a cycle) becomes trash. That behavior cannot be extended to cyclic trash short of (as above) running a cyclic gc pass extremely frequently. I don't know of any language that guarantees all garbage will be collected "right away". Do you? CPython does much more in that respect (due to primarily relying on refcounting) than most. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41389> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com