Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

I started to add this comment to #33218 but Raymond closed that ticket while I 
was editing it.

In 3.6, dicts preserving insertion order remains an implementation detail that 
cannot be relied on. It only becomes a guarantee in 3.7.

Even in 3.7, I think that it remains best to think of dicts as fundamentally 
unordered. Dicts might preserve insertion order, but there's no interface for 
extracting the n-th item, or re-ordering the keys into some alternative order, 
and for the purposes of equality comparisons, the order is ignored.

I propose changing the description from "It is best to think of a dictionary as 
an unordered set of key: value pairs" to something like:


    Dicts are an otherwise unordered set of key:value pairs
    that remember the order keys were inserted.


and references to "arbitrary order" should be replaced by "insertion order". 
But by no means should we suggest that dicts are fundamentally orderable 
(sortable).

----------
nosy: +steven.daprano

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32337>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to