On Fri, Sep 19, 2014 at 9:46 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > Chris Angelico wrote: > >> On Fri, Sep 19, 2014 at 8:59 PM, Steven D'Aprano >> <steve+comp.lang.pyt...@pearwood.info> wrote: >>> Here's a proof of concept of what would be allowed: > [...] >> Also, this can't possibly offer the same guarantee. Watch: >> >> d = MyDict(some_lot_of_items) >> d.values(); d.items() >> # mutate the dict in whatever way you like >> pairs = zip(d.keys(), d.values()) >> >> This might well create mismatched pairs, because after generating the >> keys() return value, the list gets shuffled, prior to generating >> values() in the same expression. This would not be allowed. > > That would be a bug, and an easy one to fix. Every mutation of the dict > would have to reset the internal flags back to the starting state.
What if there's no mutation, then? Just calling values() and items() means that the zip of keys and values will make mismatches. ChrisA -- https://mail.python.org/mailman/listinfo/python-list