Python 2.7 and later have OrderedDict in the collections
module, so you should consider that as 'standard'. If its functionality is enough you should probably be using that.
However its implementation approach is minimalistic and if that is not enough you should look at odict by Foord/Larossa or ordereddict (by me) as in that case those are a better fit. Both implementations are a superset of the functionality provided by collections.OrderedDict
. The difference between the two being, that odict
is pure python and ordereddict
a much faster C
extension module.
A minimalistic approach is not necessarily better even if it provides all the functionality you need: e.g. collections.OrderedDict
did initially have a bug when returning the repr()
of a OrderedDict
nested in one of its own values. A bug that could have been found earlier, had the subset, the small subset OrderedDict can handle, of unittests of the older ordereddict
been used.