-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Improve annotation application performance #11186
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
Conversation
Also remove unnecessary schema copy.
Deploying pydantic-docs with
|
Latest commit: |
d285728
|
Status: | ✅ Deploy successful! |
Preview URL: | https://d7bfb8e4.pydantic-docs.pages.dev |
Branch Preview URL: | https://ann-application-perf-test.pydantic-docs.pages.dev |
CodSpeed Performance ReportMerging #11186 will improve performances by 7.02%Comparing Summary
Benchmarks breakdown
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
@@ -2106,7 +2106,7 @@ def _apply_single_annotation(self, schema: core_schema.CoreSchema, metadata: Any | |||
return self.defs.definitions[new_ref] | |||
schema['ref'] = new_ref # type: ignore | |||
|
|||
maybe_updated_schema = _known_annotated_metadata.apply_known_metadata(metadata, schema.copy()) | |||
maybe_updated_schema = _known_annotated_metadata.apply_known_metadata(metadata, schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apply_known_metadata
already copies schema
schema = get_inner_schema(source) | ||
schema = self._apply_single_annotation(schema, annotation) | ||
schema = self._apply_single_annotation_json_schema(schema, annotation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way, we don't go through _appy_single_annotation*
for annotations with a custom __get_pydantic_core_schema__
as it is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find, thanks for making reviewing the perf diff easy!
Just as a side note, I think there's still a lot to do with #10036, I'm happy to take a deeper look at this for v2.11 :) |
Also remove unnecessary schema copy.
Change Summary
Related issue number
Checklist