Code review comment for ~cjwatson/launchpad:six-dict-iter

Revision history for this message
Colin Watson (cjwatson) wrote :

Well, but that last isn't true; on Python 2, six.itervalues(dict) is implemented using dict.itervalues(), not using iter(d.values()) as it is on Python 3 (where .values() doesn't materialise the whole list).

Mainly I wanted to use a reasonably obvious mechanical transformation that didn't require me to reason about whether there might be a real performance implication in any of the >130 cases here. A secondary benefit was that it means that we don't lose information as part of this commit: we can still look at the existing calls to dict.values and consider whether those might need to take a copy (I've certainly run across some that do, for example because the loop body deletes items from the dict). Doing that across the whole tree is a large chunk of work that I haven't tackled yet.

So, it's true it's not strictly necessary to use six.iter*, but I did think that it was worthwhile and better than reverting to bare .values() etc. in a systematic way.

« Back to merge proposal