Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sydney-runkle merged 1 commit intomainfromann-application-perf-test
Dec 30, 2024

Conversation

Viicos
Copy link
Member

Also remove unnecessary schema copy.

Change Summary

Related issue number

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review,please add a comment including the phrase "please review" to assign reviewers

Also remove unnecessary schema copy.
@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelDec 28, 2024
@cloudflare-workers-and-pagesCloudflare Workers and Pages

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

@codspeed-hqCodSpeed HQ
Copy link

CodSpeed Performance Report

Merging#11186 willimprove performances by 7.02%

Comparingann-application-perf-test (d285728) withmain (3294b9f)

Summary

⚡ 1 improvements
✅ 45 untouched benchmarks

Benchmarks breakdown

Benchmarkmainann-application-perf-testChange
test_tagged_union_with_callable_discriminator_schema_generation1.9 ms1.8 ms+7.02%

@github-actionsGitHub Actions
Copy link
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic/_internal
  _generate_schema.py
Project Total 

This report was generated bypython-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)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

apply_known_metadata already copiesschema

sydney-runkle reacted with thumbs up emoji
Comment on lines +2143 to +2145
schema = get_inner_schema(source)
schema = self._apply_single_annotation(schema, annotation)
schema = self._apply_single_annotation_json_schema(schema, annotation)
Copy link
MemberAuthor

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.

sydney-runkle reacted with thumbs up emoji
@ViicosViicos marked this pull request as ready for reviewDecember 29, 2024 15:42
@Viicos
Copy link
MemberAuthor

Viicos commentedDec 29, 2024
edited
Loading

This mostly improves performance fortest_field_validators_serializers (which is ignored in codspeed), or for any similar use case where annotations with a custom__get_pydantic_core_schema__ method is used:

image

Copy link
Contributor

@sydney-runklesydney-runkle left a 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!

@sydney-runklesydney-runkle added relnotes-performanceUsed for performance improvements. and removed relnotes-fixUsed for bugfixes. labelsDec 30, 2024
@sydney-runkle
Copy link
Contributor

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 :)

@sydney-runklesydney-runkle merged commit7b7db4f intomainDec 30, 2024
59 checks passed
@sydney-runklesydney-runkle deleted the ann-application-perf-test branchDecember 30, 2024 15:38
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sydney-runklesydney-runklesydney-runkle approved these changes

Assignees
No one assigned
Labels
relnotes-performanceUsed for performance improvements.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Viicos@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp