Feb. 27, 2014
4:27 a.m.
On Wed, Feb 26, 2014 at 01:17:59PM -0800, David Mertz wrote:
Have we actually been promised that d.keys() and d.values() walk the (unordered) dictionary in the same order, for every Python implementation/version?
Yes. Any implementation which breaks the invariant that keys and values will be given in the same order (so long as there are no intervening changes to the dict) is buggy. http://docs.python.org/3/library/stdtypes.html#dictionary-view-objects
I could trivially subclass dict to make a pretty good dictionary that violated this invariant, e.g.:
The invariant only applies to dict :-) -- Steven