[Python-Dev] Guarantee ordered dict literals in v3.7?

Raymond Hettinger raymond.hettinger at gmail.com
Tue Nov 7 00:11:00 EST 2017


> On Nov 6, 2017, at 8:05 PM, David Mertz <mertz at gnosis.cx> wrote:
> 
> I strongly opposed adding an ordered guarantee to regular dicts. If the implementation happens to keep that, great. Maybe OrderedDict can be rewritten to use the dict implementation. But the evidence that all implementations will always be fine with this restraint feels poor, and we have a perfectly good explicit OrderedDict for those who want that.

I think this post is dismissive of the value that users would get from having reliable ordering by default.

Having worked with Python 3.6 for a while, it is repeatedly delightful to encounter the effects of ordering.  When debugging, it is a pleasure to be able to easily see what has changed in a dictionary.  When creating XML, it is joy to see the attribs show in the same order you added them.  When reading a configuration, modifying it, and writing it back out, it is a godsend to have it written out in about the same order you originally typed it in.  The same applies to reading and writing JSON.  When adding a VIA header in a HTTP proxy, it is nice to not permute the order of the other headers. When generating url query strings for REST APIs, it is nice have the parameter order match documented examples.

We've lived without order for so long that it seems that some of us now think data scrambling is a virtue.  But it isn't.  Scrambled data is the opposite of human friendly.


Raymond


P.S. Especially during debugging, it is often inconvenient, difficult, or impossible to bring in an OrderedDict after the fact or to inject one into third-party code that is returning regular dicts.  Just because we have OrderedDict in collections doesn't mean that we always get to take advantage of it.  Plain dicts get served to us whether we want them or not.


More information about the Python-Dev mailing list