Derived from the Perflint linter.
Fix is always available.
What it does#
Checks for uses of
dict.items() that discard either the key or the value
when iterating over the dictionary.
Why is this bad?#
If you only need the keys or values of a dictionary, you should use
dict.values() respectively, instead of
These specialized methods are more efficient than
dict.items(), as they
avoid allocating tuples for every item in the dictionary. They also
communicate the intent of the code more clearly.
Note that, as with all
perflint rules, this is only intended as a
micro-optimization, and will have a negligible impact on performance in