Repository navigation
Remove redundant .keys() in dict membership and iteration - #4263
Merged
Merged
Conversation
`x in d.keys()` and `reversed(d.keys())` behave identically to operating on the dict directly, dropping two unnecessary dict-view allocations. No behavior change.
Contributor
Author
|
Hello @rambleraptor , @Fokko could you please review the changes I have made. |
Fokko
approved these changes
Nov 2, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
Certainly @prabhleen2317, thanks for cleaning this up 👍 Less is more!
Contributor
Author
|
Thankyou so much @Fokko for merging and reviewing. I really appreciate your time and effort :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
x in d.keys()andreversed(d.keys())are equivalent to operating on the dict directly, so the.keys()calls are redundant and allocate a throwaway dict-view.pyiceberg/catalog/dynamodb.py:prop not in table_dict.keys()→prop not in table_dictpyiceberg/table/update/snapshot.py:reversed(groups.keys())→reversed(groups)Both are behavior-preserving: membership and reverse-iteration over a dict operate on its keys, in the same order. No code or tests relied on the removed
.keys()calls.