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

Barry Warsaw barry at python.org
Tue Dec 19 11:14:07 EST 2017


On Dec 18, 2017, at 22:37, Nathaniel Smith <njs at pobox.com> wrote:

> Wait, what? Why would changing pprint (so that it accurately reflects
> dict's new underlying semantics!) be a breaking change? Are you
> suggesting it shouldn't be changed in 3.7?

As others have pointed out, exactly because the current behavior is documented.  And we all know that if it’s documented (and often even if it’s not, but that’s besides the point here) it will be relied upon.

So we can’t change the default behavior.  But I have no problems conceptually with giving users options.  The devil is in the details though, e.g. should we special case dictionary sorting only?  Should we use a sort `key` to mirror sorted() and list.sort()?

We can figure those things out and whether it’s even worth doing.  I don’t think that’s PEP-worthy, so if someone is sufficiently motivated, please open an issue on bpo.

Cheers,
-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171219/677d10b9/attachment.sig>


More information about the Python-Dev mailing list