Skip to content
Unverified Commit fb37242e authored by Niels Thykier's avatar Niels Thykier
Browse files

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: default avatarNiels Thykier <niels@thykier.net>
parent 23eda7ff
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment