[issue19332] Guard against changing dict during iteration

Serhiy Storchaka report at bugs.python.org
Wed Oct 23 21:46:02 CEST 2013


Serhiy Storchaka added the comment:

In the first patch the counter was placed in the _dictkeysobject structure. In the second place it is placed in the PyDictObject so it now has no memory cost. Access time to new counter for non-modifying operations is same as in current code. The only additional cost is time cost for modifying operations. But modifying operations is usually much rare than non-modifying operations, and the incrementing one field takes only small part of the time needed for all operation. I don't think this will affect total performance of real programs.

----------
Added file: http://bugs.python.org/file32319/dict_mutating_iteration_2.patch

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


More information about the Python-bugs-list mailing list