3 ms·
FYI, dicts are now ordered by default as of Python 3.6.
by Cyph0n 9y ago
FYI, dicts are now ordered by default as of Python 3.6.
- cpburns2009 9y agoThat's an implementation detail, and shouldn't be relied upon. If you want an ordered dictionary, you should use collections.OrderedDict.
- Cyph0n 9y agoTrue, but if you need both key ordering and performance, dict is the better option.
- westurner 9y agoIt's now the spec for 3.6+. > #python news: @gvanrossum just pronounced that dicts are now guaranteed to retain insertion order. This is the end of a long journey. https://twitter.com/raymondh/status/941709626545864704 https://twitter.com/raymondh/status/941709626545864704 More here: https://www.reddit.com/r/Python/comments/7jyluw/dict_knownordered_versus_ordereddict_an/ https://www.reddit.com/r/Python/comments/7jyluw/dict_knownor... OrderedDicts are backwards-compatible and are guaranteed to maintain order after deletion.