Rewrite some uses of keys() in if-statements
This rewrites the following statements:
if a in b.keys():
to
if a in b:
At the moment, both variants are cheap (i.e. O(1)) operations.
However, the 2to3 will blindly rewrite the former into a more
expensive variant, namely:
if a in list(b.keys()):
Sadly, this becomes O(|b|) as __contains__ on a list is a lot more
expensive than it is on a directory/set-like structure.
Signed-off-by:
Niels Thykier <niels@thykier.net>
Loading
Please register or sign in to comment