Skip to content

Conversation

@Fokko
Copy link
Contributor

@Fokko Fokko commented Mar 25, 2025

Rationale for this change

Right now we deserialize the JSON into a dict, which is then passed into the Pydantic model. It is better to fully delegate this to pydantic because it is probably faster, and we can detect when models are created from json or from Python dicts.

Required by #1770

This is also a recommendation by Pydantic itself: https://docs.pydantic.dev/latest/concepts/performance/#in-general-use-model_validate_json-not-model_validatejsonloads

Are these changes tested?

Existing tests

Are there any user-facing changes?

No

Right now we deserialize the JSON into a dict, which is then passed
into the Pydantic model. It is better to fully delegate this to
pydantic because it is probably faster, and we can detect when
models are created from json or from Python dicts.

Required by apache#1770
Copy link
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

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

LGTM
I double checked all regex matching \*\*.*\.json is in rest.py and this PR addressed all of them

@Fokko Fokko merged commit 172d9a7 into apache:main Mar 25, 2025
7 checks passed
@Fokko Fokko deleted the fd-delegate-parsing-to-pydantic branch March 25, 2025 19:39
gabeiglio pushed a commit to Netflix/iceberg-python that referenced this pull request Aug 13, 2025
# Rationale for this change

Right now we deserialize the JSON into a dict, which is then passed into
the Pydantic model. It is better to fully delegate this to pydantic
because it is probably faster, and we can detect when models are created
from json or from Python dicts.

Required by apache#1770

This is also a recommendation by Pydantic itself:
https://docs.pydantic.dev/latest/concepts/performance/#in-general-use-model_validate_json-not-model_validatejsonloads

# Are these changes tested?

Existing tests

# Are there any user-facing changes?

No

<!-- In the case of user-facing changes, please add the changelog label.
-->
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