Python dictionaries are insertion-ordered from 3.7+
Last updated
Was this helpful?
Last updated
Was this helpful?
They are insertion-ordered in CPython implementation of Python 3.6 as an implementation detail. that it is officially part of the language spec in Python 3.7. From :
Changed in version 3.7: Dictionary order is guaranteed to be insertion order. This behavior was implementation detail of CPython from 3.6.
list(d)
on a dictionary returns a list of all the keys used in the dictionary, in insertion order.
Sets are still unordered.