[Python-Dev] Lockstep iteration - eureka! (original) (raw)

Tim Peters tim_one@email.msn.com
Mon, 14 Aug 2000 12:42:14 -0400


[Paul Prescod]

Let me throw out another idea. What if sequences just had .items() methods?

[Barry A. Warsaw]

Funny, I remember talking with Guido about this on a lunch trip several years ago. Tim will probably chime in that /he/ proposed it in the Python 0.9.3 time frame. :)

Not me, although someone proposed it at least that early, perhaps at 0.9.1 already. IIRC, that was the very first time Guido used the term "hypergeneralization" in a cluck-cluck kind of public way. That is, sequences and mappings are different concepts in Python, and intentionally so. Don't know how he feels now.

But if you add seq.items(), you had better add seq.keys() too, and seq.values() as a synonym for seq[:]. I guess the perceived advantage of adding seq.items() is that it supplies yet another incredibly slow and convoluted way to get at the for-loop index? "Ah, that's the ticket! Let's allocate gazillabytes of storage and compute all the indexes into a massive data structure up front, and then we can use the loop index that's already sitting there for free anyway to index into that and get back a redundant copy of itself!" .

not-a-good-sign-when-common-sense-is-offended-ly y'rs - tim