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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to