Advantages of Dict over OrderDict

I find it annoying that Python dictionaries do not store keys in insertion order. I recently started using OrderedDict, which is more convenient to use because it covers this drawback (for example, iterating over the columns of a CSV file, where the column order should correspond to the order of the dictionary keys).

However, are there any distinctive advantages the dictionary has for OrderedDict? If so, what are they?

+5
source share
1 answer

A dictionary is a simpler data structure that takes up less space and is a little faster. It should support only a hash table, and OrderedDict supports both a hash table and a linked list.

If you do not need the key order, go to a simpler option.

Also, do not lose sight of the language support for dictations. It’s easy to type {k1: v1, k2: v2} . This is another victory for dictons. Perhaps unfair, but there you go.

+4
source

All Articles