[issue19414] OrderedDict.values() behavior for modified instance

Armin Rigo report at bugs.python.org
Sun Oct 27 22:58:46 CET 2013


Armin Rigo added the comment:

Modifying an ordered dict while iterating over it can be officially classified as an ok think to do, but then the precise behavior must described in the documentation in some details, with of course matching implementation(s) and tests.  I mean by that that the behavior should not be "it might miss some elements", but rather something precise like: consider the ordered dict as simply a list of its elements, and consider __delitem__ as replacing an element with NULL.  Then forward or backward iteration works like forward or backward iteration over this list, with the additional rule that NULL elements are skipped over.

It would imho be a good possible solution, but it obviously requires more effort.

----------

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


More information about the Python-bugs-list mailing list