This is an archive of the discontinued Mercurial Phabricator instance.

py3: define and use pycompat.itervalues()
ClosedPublic

Authored by indygreg on Oct 7 2019, 4:04 PM.

Details

Summary

.itervalues() only exists on Python 2. Python 3's equivalent is
.values(). But we don't want to blindly use .values() everywhere
because on Python 2, it will create a list, which will have performance
implications.

This commit introduces pycompat.itervalues() which will call the appropriate
method on the passed object. We update all callers of obj.itervalues()
to pycompat.itervalues(obj) instead.

With this commit, the only source tranforming remaining is for
iteritems(). Victory is near...

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Oct 7 2019, 4:04 PM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.