Skip to content

perf(types): avoid double iteration in transform_dict_value_to_str - #3988

Merged
Fokko merged 1 commit into
apache:mainfrom
ArulJerald:optimization/optimize-transform-dict-value-to-str
Sep 18, 2026
Merged

Fokko merged 1 commit into
apache:mainfrom
ArulJerald:optimization/optimize-transform-dict-value-to-str

Conversation

@ArulJerald

Copy link
Copy Markdown
Contributor

Summary

  • transform_dict_value_to_str iterated over dict.items() twice: once to
    validate no value is None, once more in a dict comprehension to convert
    values to strings. Combined into a single pass.
  • Renamed the parameter from dict to d so it no longer shadows the
    builtin type.

Closes #3987

Test plan

  • uv run pytest tests/test_types.py -k transform_dict_value_to_str
  • ruff check pyiceberg/types.py

Combine the None-validation and str-conversion loops over dict.items()
into a single pass, and rename the `dict` parameter to `d` to stop
shadowing the builtin.

Fixes apache#3987

@ebyhr ebyhr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is more of a cosmetic code quality fix than a meaningful perf win, but still worth having.

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

Nice one @ArulJerald Thanks!

@Fokko
Fokko added this pull request to the merge queue Sep 18, 2026
Merged via the queue into apache:main with commit a63c87f Sep 18, 2026
21 checks passed
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.

Optimization: Avoid double iteration over dictionary items in transform_dict_value_to_str

3 participants