<div dir="ltr"><div><div>I'm in favor of stating that dict keeps order as part of the language spec.<br><br></div>However re-reading <a href="https://mail.python.org/pipermail/python-dev/2017-November/150381.html">https://mail.python.org/pipermail/python-dev/2017-November/150381.html</a> there's still a point of debate: should it be allowed if dict reorders  after deletion (presumably as a result of a rehash)? I'm in favor of prescribing that the order should be preserved even in that case, but I realize there's additional implementation work to be done. Inada-san, what do you think of this?<br><br></div>--Guido<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 14, 2017 at 6:03 PM, INADA Naoki <span dir="ltr"><<a href="mailto:songofacandy@gmail.com" target="_blank">songofacandy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, folks.<br>
<br>
TLDR, was the final decision made already?<br>
<br>
If "dict keeps insertion order" is not language spec and we<br>
continue to recommend people to use OrderedDict to keep<br>
order, I want to optimize OrderedDict for creation/iteration<br>
and memory usage.  (See <a href="https://bugs.python.org/issue31265#msg301942" rel="noreferrer" target="_blank">https://bugs.python.org/<wbr>issue31265#msg301942</a> )<br>
<br>
If dict ordering is language spec, I'll stop the effort and<br>
use remaining time to another optimizations.<br>
<br>
My thought is, +1 to make it language spec.<br>
<br>
* PHP (PHP 7.2 interpreter is faster than Python) keeps insertion order.<br>
  So even we make it language spec, I think we have enough room<br>
  to optimize.<br>
<br>
* It can make stop discussion like "Does X keeps insertion order?<br>
  It's language spec?", "What about Y? Z?".  Everything on top of dict<br>
  keeps insertion order.  It's simple to learn and explain.<br>
<br>
Regards,<br>
INADA Naoki  <<a href="mailto:songofacandy@gmail.com">songofacandy@gmail.com</a>><br>
<div><div class="h5"><br>
<br>
On Sun, Nov 5, 2017 at 3:35 AM, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
> This sounds reasonable -- I think when we introduced this in 3.6 we were<br>
> worried that other implementations (e.g. Jython) would have a problem with<br>
> this, but AFAIK they've reported back that they can do this just fine. So<br>
> let's just document this as a language guarantee.<br>
><br>
> On Sat, Nov 4, 2017 at 10:30 AM, Stefan Krah <<a href="mailto:stefan@bytereef.org">stefan@bytereef.org</a>> wrote:<br>
>><br>
>><br>
>> Hello,<br>
>><br>
>> would it be possible to guarantee that dict literals are ordered in v3.7?<br>
>><br>
>><br>
>> The issue is well-known and the workarounds are tedious, example:<br>
>><br>
>><br>
>> <a href="https://mail.python.org/pipermail/python-ideas/2015-December/037423.html" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>pipermail/python-ideas/2015-<wbr>December/037423.html</a><br>
>><br>
>><br>
>> If the feature is guaranteed now, people can rely on it around v3.9.<br>
>><br>
>><br>
>><br>
>> Stefan Krah<br>
>><br>
>><br>
>><br>
>> ______________________________<wbr>_________________<br>
>> Python-Dev mailing list<br>
>> <a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
>> <a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
>> Unsubscribe:<br>
>> <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>guido%40python.org</a><br>
><br>
><br>
><br>
><br>
> --<br>
> --Guido van Rossum (<a href="http://python.org/~guido" rel="noreferrer" target="_blank">python.org/~guido</a>)<br>
><br>
> ______________________________<wbr>_________________<br>
> Python-Dev mailing list<br>
> <a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
> Unsubscribe:<br>
</div></div>> <a href="https://mail.python.org/mailman/options/python-dev/songofacandy%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>songofacandy%40gmail.com</a><br>
><br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>