Re:Migrating to Python 3 with pleasure
by dbcurtis on Sunday February 04, 2018 @11:42PM
(#16306643)
Ordereddict has been available for ages. Why should I pay for the overhead in the 98% of the cases where I don't need it.
[ Parent
| on HN ]
Re:Migrating to Python 3 with pleasure
by alexbecker on Monday February 05, 2018 @12:10AM
(#16306745)
The new dict implementation was introduced in 3.5 (with forced order randomization, which was removed in 3.6) because it is faster and uses less memory than the previous non-ordered dict. Ordering is merely a nice byproduct. So you're not paying any penalty.
OrderedDict is fundamentally different because it is designed to allow inserting/removing keys in the middle of the ordering in O(1) time. It does not use the new dict under the hood, or vice-versa.
Actually, 3.7 are not always ordered. If you delete a key, order is not guaranteed anymore. For performance reasons.
Are you sure about that? I thought they considered that but decided to just make them always ordered in the end.