Commit 396ecb9c authored by Andrés Delfino's avatar Andrés Delfino Committed by INADA Naoki

bpo-33799: Remove non-ordered dicts comments from FAQ

parent b1f69029
...@@ -495,11 +495,7 @@ on the key and a per-process seed; for example, "Python" could hash to ...@@ -495,11 +495,7 @@ on the key and a per-process seed; for example, "Python" could hash to
to 1142331976. The hash code is then used to calculate a location in an to 1142331976. The hash code is then used to calculate a location in an
internal array where the value will be stored. Assuming that you're storing internal array where the value will be stored. Assuming that you're storing
keys that all have different hash values, this means that dictionaries take keys that all have different hash values, this means that dictionaries take
constant time -- O(1), in computer science notation -- to retrieve a key. It constant time -- O(1), in computer science notation -- to retrieve a key.
also means that no sorted order of the keys is maintained, and traversing the
array as the ``.keys()`` and ``.items()`` do will output the dictionary's
content in some arbitrary jumbled order that can change with every invocation of
a program.
Why must dictionary keys be immutable? Why must dictionary keys be immutable?
......
...@@ -1315,11 +1315,6 @@ that final assignment still results in an error, because tuples are immutable. ...@@ -1315,11 +1315,6 @@ that final assignment still results in an error, because tuples are immutable.
Dictionaries Dictionaries
============ ============
How can I get a dictionary to store and display its keys in a consistent order?
-------------------------------------------------------------------------------
Use :class:`collections.OrderedDict`.
I want to do a complicated sort: can you do a Schwartzian Transform in Python? I want to do a complicated sort: can you do a Schwartzian Transform in Python?
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment