-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
consider-dictionary-membership #4069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Milestone
Comments
DanielNoord
added a commit
to DanielNoord/pylint
that referenced
this issue
Sep 13, 2021
4 tasks
cdce8p
pushed a commit
to DanielNoord/pylint
that referenced
this issue
Sep 14, 2021
stanislavlevin
added a commit
to stanislavlevin/fc-admin
that referenced
this issue
Feb 17, 2022
> Emitted when the keys of a dictionary are iterated through the ``.keys()`` method or when ``.keys()`` is used for a membership check. It is enough to iterate through the dictionary itself, ``for key in dictionary``. For membership checks, ``if key in dictionary`` is faster. See pylint-dev/pylint#4069 Fixes: fleet-commander#279 Signed-off-by: Stanislav Levin <[email protected]>
stanislavlevin
added a commit
to stanislavlevin/fc-admin
that referenced
this issue
Feb 17, 2022
> Emitted when the keys of a dictionary are iterated through the ``.keys()`` method or when ``.keys()`` is used for a membership check. It is enough to iterate through the dictionary itself, ``for key in dictionary``. For membership checks, ``if key in dictionary`` is faster. See pylint-dev/pylint#4069 Fixes: fleet-commander#279 Signed-off-by: Stanislav Levin <[email protected]>
olivergs
pushed a commit
to fleet-commander/fc-admin
that referenced
this issue
Mar 3, 2022
> Emitted when the keys of a dictionary are iterated through the ``.keys()`` method or when ``.keys()`` is used for a membership check. It is enough to iterate through the dictionary itself, ``for key in dictionary``. For membership checks, ``if key in dictionary`` is faster. See pylint-dev/pylint#4069 Fixes: #279 Signed-off-by: Stanislav Levin <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When testing if a key is contained in a dictionary, it's O(1) to use
in
directly on the dict object as opposed to O(N) through.keys()
.So along the lines of
consider-iterating-dictionary
, there should be a check for this that suggests removingkeys()
.The text was updated successfully, but these errors were encountered: