[Python-ideas] Method chaining notation
Steven D'Aprano
steve at pearwood.info
Thu Feb 27 05:27:28 CET 2014
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
More information about the Python-ideas
mailing list