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

Stephen J. Turnbull turnbull.stephen.fw at u.tsukuba.ac.jp
Tue Dec 19 11:49:36 EST 2017


Nathaniel Smith writes:

 > To make sure I understand, do you actually have a script like this, or
 > is this hypothetical?

I have a couple of doctests that assume that pprint will sort by key,
yes.  It makes the tests look quite a bit nicer by pprinting the
output, and I get sorting (which matters for some older Pythons) for
free.  (I admit I don't actually use those tests with older Pythons,
but the principle stands.)

I don't see why we don't do the obvious, namely add the option to use
"native" order to the PrettyPrinter class, with the default being
backward compatible.


-- 
Associate Professor              Division of Policy and Planning Science
http://turnbull/sk.tsukuba.ac.jp/     Faculty of Systems and Information
Email: turnbull at sk.tsukuba.ac.jp                   University of Tsukuba
Tel: 029-853-5175                 Tennodai 1-1-1, Tsukuba 305-8573 JAPAN


More information about the Python-Dev mailing list