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

Guido van Rossum guido at python.org
Fri Dec 15 16:47:04 EST 2017


On Fri, Dec 15, 2017 at 12:45 PM, Raymond Hettinger <
raymond.hettinger at gmail.com> wrote:

>
> > On Dec 15, 2017, at 7:53 AM, Guido van Rossum <guido at python.org> wrote:
> >
> > Make it so. "Dict keeps insertion order" is the ruling.
>
> On Twitter, someone raised an interesting question.
>
> Is the guarantee just for 3.7 and later?  Or will the blessing also cover
> 3.6 where it is already true.
>
> The 3.6 guidance is to use OrderedDict() when ordering is required.  As of
> now, that guidance seems superfluous and may no longer be a sensible
> practice.  For example, it would be nice for Eric Smith when he does his
> 3.6 dataclasses backport to not have to put OrderedDict back in the code.
>

For 3.6 we can't change the language specs, we can just document how it
works in CPython. I don't know what other Python implementations do in
their version that's supposed to be compatible with 3.6 but I don't want to
retroactively declare them non-conforming. (However for 3.7 they have to
follow suit.) I also don't think that the "it stays ordered across
deletions" part of the ruling is true in CPython 3.6.

I don't know what guidance to give Eric, because I don't know what other
implementations do nor whether Eric cares about being compatible with
those. IIUC micropython does not guarantee this currently, but I don't know
if they claim Python 3.6 compatibility -- in fact I can't find any document
that specifies the Python version they're compatible with more precisely
than "Python 3".

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171215/543c7d84/attachment.html>


More information about the Python-Dev mailing list