Message73072
>> Well, sure, but heaven only knows what an application programmer will
>> do...
Antoine> If the docs clearly explain that there is no guarantee, we
Antoine> don't need heaven. I would find it strange to potentially ruin
Antoine> performance just for a guarantee which has no useful purpose.
From <http://docs.python.org/lib/typesmapping.html>:
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(a.values(), a.keys())". The same
relationship holds for the iterkeys() and itervalues() methods: "pairs =
zip(a.itervalues(), a.iterkeys())" provides the same value for
pairs. Another way to create the same list is "pairs = [(v, k) for (k,
v) in a.iteritems()]".
While the emphasis is on dictionaries, it seems to me that page describes
the notation and properties of mappings in general, not specifically
dictionaries.
I think it might be worthwhile to get a verdict from Guido on this one.
Skip |
|
Date |
User |
Action |
Args |
2008-09-12 01:28:58 | skip.montanaro | set | recipients:
+ skip.montanaro, rhettinger, gregory.p.smith, jcea, ghaering, josiahcarlson, pitrou, gregburd |
2008-09-12 01:28:29 | skip.montanaro | link | issue3783 messages |
2008-09-12 01:28:27 | skip.montanaro | create | |
|