> On Dec 13, 2016, at 12:48 PM, Guido van Rossum <gu...@python.org> wrote: > >> On Tue, Dec 13, 2016 at 8:52 AM, Eric V. Smith <e...@trueblade.com> wrote: >> >> > On Dec 13, 2016, at 11:42 AM, Raymond Hettinger >> > <raymond.hettin...@gmail.com> wrote: >> > >> >> On Dec 13, 2016, at 1:51 AM, Max Moroz <maxmo...@gmail.com> wrote: >> >> >> >> Would it be worth ensuring that an exception is ALWAYS raised if a key >> >> is added to or deleted from a dictionary during iteration? >> >> <snip> >> >> I suspect the cost of a more comprehensive error reporting is not >> >> worth the benefit, but I thought I'd ask anyway. >> > >> > I think what we have has proven itself to be good enough to detect the >> > common cases, and it isn't worth it to have dicts grow an extra field >> > which has to be checked or updated on every operation. >> > >> >> I agree that we shouldn't complicate things, but wouldn't PEP 509 be a cheap >> way to check this? > > IIUC the private version gets updated every time the dict gets modified -- > but what we need here should only trigger when a key is added or removed, not > when a value is updated. (It's a guarantee that updating the value doesn't > change the iteration order -- though perhaps it isn't spelled out, it's > implicit.) >
Ah, yes. That's over-zealous for this case. > I agree with Raymond that we should not change anything. Agreed. Eric.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com