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

Do not reuse validators and serializers during model rebuild#11429

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
Viicos merged 1 commit intomainfrommodel-rebuild-val-ser
Feb 12, 2025

Conversation

Viicos
Copy link
Member

As we look forcls.__pydantic_validator/serializer__ in pydantic-core, we don't want to mistakenly reuse them.

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

@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelFeb 11, 2025
@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedFeb 11, 2025
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:059a706
Status: ✅  Deploy successful!
Preview URL:https://414fc1ce.pydantic-docs.pages.dev
Branch Preview URL:https://model-rebuild-val-ser.pydantic-docs.pages.dev

View logs

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedFeb 11, 2025
edited
Loading

CodSpeed Performance Report

Merging#11429 willdegrade performances by 7.16%

Comparingmodel-rebuild-val-ser (059a706) withmain (a1f12c7)

Summary

❌ 9 regressions
✅ 37 untouched benchmarks

⚠️Please fix the performance issues oracknowledge them on CodSpeed.

Benchmarks breakdown

BenchmarkBASEHEADChange
test_complex_model_schema_generation1.4 ms1.5 ms-6.02%
test_recursive_model_schema_generation795.3 µs845 µs-5.87%
test_simple_model_schema_generation576.6 µs614.2 µs-6.13%
test_tagged_union_with_callable_discriminator_schema_generation995 µs1,056.5 µs-5.83%
test_tagged_union_with_str_discriminator_schema_generation995.4 µs1,072.2 µs-7.16%
test_deeply_nested_recursive_model_schema_generation1 ms1.1 ms-5.52%
test_generic_recursive_model_schema_generation699.7 µs742.2 µs-5.72%
test_recursive_discriminated_union_with_base_model1.3 ms1.4 ms-6.75%
test_simple_recursive_model_schema_generation580.3 µs620.9 µs-6.53%

@github-actionsGitHub Actions
Copy link
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  dataclasses.py
  main.py
Project Total 

This report was generated bypython-coverage-comment-action

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.

I approve of these logical change, but I'm equally perplexed by the benchmark changes.

I think we should investigate before merging, but obviously this should make its way into v2.11.

As we look for `cls.__pydantic_validator/serializer__` inpydantic-core, we don't want to mistakenly reuse them.
@Viicos
Copy link
MemberAuthor

So I'm still not sure why the performance difference comes from pydantic-core:

image

But I now realize it was just improved by the reusable validators/serializers in pydantic-core (see#11402), which doesn't make sense for benchmarks such astest_simple_model_schema_generation, which doesn't use any nested models:

deftest_simple_model_schema_generation(benchmark)->None:
classSimpleModel(DeferredModel):
field1:str
field2:int
field3:float
benchmark(rebuild_model,SimpleModel)

sydney-runkle reacted with confused emoji

@sydney-runkle
Copy link
Contributor

Yeah, this regression is a bit mysterious. Though, it seems like for cases with nested models, we still see all of the perf wins that we wanted to from previous improvements.

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.

This fix is necessary, and I believe we've diagnosed the codspeed changes as not blocking here.@Viicos if you can acknowledge them in codspeed, happy to merge this.

@ViicosViicos merged commit53f8ece intomainFeb 12, 2025
54 of 55 checks passed
@ViicosViicos deleted the model-rebuild-val-ser branchFebruary 12, 2025 16:27
@ViicosViicos mentioned this pull requestMay 8, 2025
5 tasks
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-fixUsed for bugfixes.
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