The collections.OrderedDict documentation describes an OrderedDict
as a
a dict that remembers the order that keys were first inserted
so the order of
for k in dict:
...
for k in dict.keys():
...
is predictable.
However, it does not say anything about values. If I only need to iterate over the values as follows, will the results respect the ordering-by-insert as well?
for v in dict.values():
...
A few quick tests here in CPython showed that to be the case, but that could just be coinicidental with the current implementation (I haven't tested any others).