This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients ghaering, gregburd, gregory.p.smith, jcea, josiahcarlson, pitrou, rhettinger, skip.montanaro
Date 2008-09-11.14:16:51
SpamBayes Score 3.261702e-11
Marked as misclassified No
Message-id <1221142609.5667.19.camel@fsol>
In-reply-to <18633.8505.897080.992468@montanaro-dyndns-org.local>
Le jeudi 11 septembre 2008 à 13:48 +0000, Skip Montanaro a écrit :
> Actually, I think Python guarantees (for dicts at least - other mappings
> should probably follow suit) that if you call keys() then call values()
> without making any changes to the dict that their orders match, e.g., that
>     zip(d.keys(), d.values()) == d.items()

Perhaps. I've never written any code that relies this, though, and it
doesn't sound like an useful guarantee since you can just use the
items() method anyway. It probably dates back to an era when list
comprehensions didn't exist, and extracting keys or values from the
items list required several lines of code and costly method calls.

Also, the point is that Python dicts can make that guarantee without
being any slower. It may not be the same for an RDBMS backend. Why?
Because, depending on the backend, index and data can be stored in
separate areas with different storage layouts (e.g. keys are in a B tree
while values are just dumped sequentially). If you only ask for
unordered keys, they will be read in optimal (sequential) index order,
and if you only ask for unordered values, they will be read in optimal
(sequential) data order, which is not the same. This is true for e.g.

(also, IMO this discussion proves that the module shouldn't be included
in Python 3.0. It's too young, its API hasn't even settled down)
Date User Action Args
2008-09-11 14:18:48pitrousetrecipients: + pitrou, skip.montanaro, rhettinger, gregory.p.smith, jcea, ghaering, josiahcarlson, gregburd
2008-09-11 14:16:52pitroulinkissue3783 messages
2008-09-11 14:16:51pitroucreate