[Python-Dev] The current dict is not an "OrderedDict"

Barry Warsaw barry at python.org
Tue Nov 7 11:36:47 EST 2017


On Nov 7, 2017, at 07:12, Antoine Pitrou <solipsis at pitrou.net> wrote:

> The problem is this is taking things to a level of precision that makes
> the guarantee tedious to remember and reason about.
> 
> The only thing that's friendly to (non-expert) users is either "dicts
> are always ordered [by insertion order], point bar" or "dicts are not
> ordered, point bar".  Anything in-between, with reservations depending
> on which operations are invoked and when, is not really helpful to the
> average (non-expert) user.
> 
> Which is why I think the user-friendliness argument does not apply if
> order ceases to be guaranteed after __del__ is called.

That’s a very important point.  If it’s difficult to explain, teach, and retain the different ordering guarantees between built-in dict and OrderedDict, it might in fact be better to not guarantee any ordering for built-in dict *in the language specification*.  Otherwise we might need a section as big as chapter 5 in the Python Language Reference just to dict ordering semantics. ;)

Cheers,
-Barry

-------------- 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/d68aecbf/attachment.sig>


More information about the Python-Dev mailing list