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

Barry Warsaw barry at python.org
Tue Nov 7 11:41:12 EST 2017

On Nov 6, 2017, at 22:33, Steven D'Aprano <steve at pearwood.info> wrote:

> I think it would be reasonable to say that builtin dicts only maintain
> insertion order for insertions, lookups, and changing the value. Any
> mutation which deletes keys may arbitrarily re-order the dict.
> If the user wants a stronger guarantee, then they should use
> OrderedDict.

In fact, that *is* leaking CPython’s implementation into the language specification.  If by chance CPython’s implementation preserved order even after key deletion, either now or in the future, would that be defined as the ordering guarantees for built-in dict in the Python Language Reference?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171107/eefa23f2/attachment.sig>

More information about the Python-Dev mailing list