Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: improve .dict speed by limiting dict calls #4302

Merged
merged 9 commits into from
Aug 14, 2024

Conversation

armandobelardo
Copy link
Contributor

@armandobelardo armandobelardo commented Aug 14, 2024

Fixes FER-2799

This PR removes the second call to .dict we'd made in order to get "exclude unsets without defaults", which was to union the dicts from exclude_unset and exclude_none in Pydantic.
For larger models, the second .dict call would take a significant amount of time, and so here during .dict we:

  • Get the list of fields set already in the model
  • Traverse the models to see if there are fields not in the field set that have non-None defaults
  • If there are, add them to the list
  • Pass this list as includes within the single pydantic .dict call

Copy link
Member

@dsinghvi dsinghvi left a comment

Choose a reason for hiding this comment

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

Looks like there is a single seed fixture failing on the python sdk?

@armandobelardo armandobelardo enabled auto-merge (squash) August 14, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants