Use identity instead of equality after validating model in __init__#10264
Merged
sydney-runkle merged 2 commits intomainfrom Aug 29, 2024
Merged
Use identity instead of equality after validating model in __init__#10264sydney-runkle merged 2 commits intomainfrom
__init__#10264sydney-runkle merged 2 commits intomainfrom
Conversation
Deploying pydantic-docs with
|
| Latest commit: |
da25e53
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1fbd0bb5.pydantic-docs.pages.dev |
| Branch Preview URL: | https://init-fix.pydantic-docs.pages.dev |
CodSpeed Performance ReportMerging #10264 will improve performances by 36.56%Comparing Summary
Benchmarks breakdown
|
Contributor
sydney-runkle
suggested changes
Aug 29, 2024
Contributor
sydney-runkle
left a comment
There was a problem hiding this comment.
Change looks good, thanks
Comment on lines
+2921
to
+2924
| return Child.model_construct(name='different!') | ||
| return Child.model_construct(name='name') | ||
|
|
||
| with pytest.warns(UserWarning, match='A custom validator is returning a value other than `self`'): | ||
| Child(name='foo') | ||
| Child(name='name') |
Contributor
There was a problem hiding this comment.
I'd rather leave these as different to illustrate the odd behavior...
Contributor
There was a problem hiding this comment.
To make it more clear, we could add an assert and a comment at the end (like self overrides, blah blah blah)
Contributor
|
Great work on the perf boost here. |
a68dc6a to
97f51c2
Compare
sydney-runkle
approved these changes
Aug 29, 2024
AdolfoVillalobos
pushed a commit
to AdolfoVillalobos/pydantic
that referenced
this pull request
Aug 30, 2024
…pydantic#10264) Co-authored-by: sydney-runkle <sydneymarierunkle@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Summary
Follow up on #10255.
This is more accurate and avoids the big performant hit.
Checklist