You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "ArulJerald (via GitHub)" <gi...@apache.org> on 2026/09/17 01:22:08 UTC
[I] Optimization: Avoid double iteration over dictionary items in transform_dict_value_to_str [iceberg-python]
ArulJerald opened a new issue, #3987:
URL: https://github.com/apache/iceberg-python/issues/3987
### Feature Request / Improvement
In the transform_dict_value_to_str function, dict.items() is iterated over twice: once to validate for None values, and a second time inside the dictionary comprehension to perform string conversion.
## Current Behavior:
`def transform_dict_value_to_str(dict: dict[str, Any]) -> dict[str, str]:
for key, value in dict.items():
if value is None:
raise ValueError(f"None type is not a supported value in properties: {key}")
return {k: str(v).lower() if isinstance(v, bool) else str(v) for k, v in dict.items()}`
## Suggested Improvement
Both validation and conversion can be completed in a single pass. Combining them improves performance on larger dictionaries and keeps the code cleaner:
`def transform_dict_value_to_str(d: dict[str, Any]) -> dict[str, str]:
result: dict[str, str] = {}
for key, value in d.items():
if value is None:
raise ValueError(f"None type is not a supported value in properties: {key}")
result[key] = str(value).lower() if isinstance(value, bool) else str(value)
return result`
(Note: Renamed parameter from built-in dict to d to avoid shadowing standard types).
### Additional Context
I am happy to open a quick Pull Request (PR) to apply this optimization
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Optimization: Avoid double iteration over dictionary items in transform_dict_value_to_str [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko closed issue #3987: Optimization: Avoid double iteration over dictionary items in transform_dict_value_to_str
URL: https://github.com/apache/iceberg-python/issues/3987
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org