[issue7105] weak dict iterators are fragile because of unpredictable GC runs

Antoine Pitrou report at bugs.python.org
Tue Nov 19 11:24:05 CET 2013


Antoine Pitrou added the comment:

> No matter how it sounds, it certainly looks cleaner in code.

It's also unsafe and invasive, since it's a process-wide setting. An
iterator can be long-lived if it's being consumed slowly, so you've
disabled garbage collection for an unknown amount of time, without the
user knowing about it. Another thread could kick in and perhaps
re-enable it for whatever reason.

Oh if someone calls gc.collect() explicitly, the solution is suddenly
defeated.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7105>
_______________________________________


More information about the Python-bugs-list mailing list