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

Antoine Pitrou solipsis at pitrou.net
Mon Nov 6 06:27:54 EST 2017


I think that Paul has a point.  Interestingly, at the same time we're
talking about guaranteeing the order of dicts, we're talking about
using another, unordered, data structure (hash array mapped tries) to
improve the performance of something that resembles a namespace.  It
seems the "unordered" part will be visible through
ExecutionContext.vars().

https://www.python.org/dev/peps/pep-0550/#enumerating-context-vars

The ordered-ness of dicts could instead become one of those stable
CPython implementation details, such as the fact that resources are
cleaned up timely by reference counting, that people nevertheless
should not rely on if they're writing portable code.

Regards

Antoine.


On Mon, 6 Nov 2017 12:18:17 +0200
Paul Sokolovsky <pmiscml at gmail.com> wrote:
> []
> 
> > I don't think that situation should change the decision,   
> 
> Indeed, it shouldn't. What may change it is the simple and obvious fact
> that there's no need to change anything, as proven by the 25-year
> history of the language.
> 
> What happens now borders on technologic surrealism - the CPython, after
> many years of persuasion, switched its dict algorithm, rather
> inefficient in terms of memory, to something else, less inefficient
> (still quite inefficient, taking "no overhead" as the baseline). That
> algorithm randomly had another property. Now there's a seemingly
> serious talk of letting that property leak into the *language spec*,
> despite the fact that there can be unlimited number of dictionary
> algorithms, most of them not having that property. 




More information about the Python-Dev mailing list