Does everyone involved know that "for x in d.iterkeys()" is equivalent to "for x in d" and works the same in Python 2 and 3? Similarly, "list(d)" is a simple, fast way to spell the Python 2 semantics of "d.keys()" that works in both versions (but I doubt it is much needed -- usually the actual code follows up with sorting, so you should use sorted(d)).
This doesn't solve itervalues() and iteritems() but I expect those are less common, and "for x, y in d.iteritems(): <blah>" is rewritten nicely as for x in d: y = d[x] <blah> If there is a measurable slowdown in the latter I would be totally okay with some kind of one-element cache for the most recent lookup. I get the social aspect of the PEP, but I think it's too high a price to pay. -- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com