Skip to content

Remove redundant .keys() in dict membership and iteration - #4263

Merged
Fokko merged 1 commit into
apache:mainfrom
prabhleen2317:remove-redundant-keys-calls
Nov 2, 2026
Merged

Fokko merged 1 commit into
apache:mainfrom
prabhleen2317:remove-redundant-keys-calls

Conversation

@prabhleen2317

Copy link
Copy Markdown
Contributor

x in d.keys() and reversed(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_dict
  • pyiceberg/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.

`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.
@prabhleen2317

Copy link
Copy Markdown
Contributor Author

Hello @rambleraptor , @Fokko could you please review the changes I have made.

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly @prabhleen2317, thanks for cleaning this up 👍 Less is more!

@Fokko
Fokko added this pull request to the merge queue Nov 2, 2026
Merged via the queue into apache:main with commit c78e18e Nov 2, 2026
20 checks passed
@prabhleen2317

Copy link
Copy Markdown
Contributor Author

Thankyou so much @Fokko for merging and reviewing. I really appreciate your time and effort :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants