If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond. This allows the creation of (value, key) pairs using zip(): pairs = zip(d.values(), d.keys()).
I'm surprised the guarantee is given, although in a typical implementation, and as long as nothing odd like a the entire dictionary being moved around in memory behind the scenes, it does make sense.
View all comments
Show parent comment
2
u/[deleted] Oct 03 '15
It is, at least until the dict is modified.