[Python-Dev] Guarantee ordered dict literals in v3.7?
Wolfgang
tds333 at mailbox.org
Mon Nov 6 09:01:39 EST 2017
Hi,
Could be missed by me but the
guarantee that dict literals are ordered implies not
that dict must be ordered in all cases.
The dict literal:
d = {"a": 1, "b": 2}
will keep the order of "a" and "b" because it is specified
as a dict literal.
But
d["c"] = 3
can change this order and it is allowed by the specification
of guaranteed ordered dict literals.
Please correct me if I am wrong.
In Python 3.6 it does not because dict
is implemented ordered and the insertion order is preserved.
Also I think we should give the whole thing more time and wait
with this guarantee. There are valid concerns against this.
Personally I like the ordering but if I need an ordered dict
it is ok for me to write this explicitly.
The **kwargs are already guaranteed to be ordered and this was
useful because the OrderedDict constructor benefits and for
other places it is useful.
But making all dict's per default ordered is another level.
Regards,
Wolfgang
More information about the Python-Dev
mailing list