-
Notifications
You must be signed in to change notification settings - Fork 247
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
fix performance regression for JSON tagged union #1552
Conversation
@@ -117,44 +117,6 @@ fn union_serialize<S>( | |||
Ok(None) | |||
} | |||
|
|||
fn tagged_union_serialize<S>( |
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.
Moved down, to be a method on TaggedUnionSerializer
.
// If extra.check is SerCheck::None, we're in a top-level union. We should thus raise | ||
// this warning | ||
let value_str = truncate_safe_repr(value, None); | ||
extra.warnings.custom_warning( |
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.
Moved this warning here from get_discriminator_value
, seemed more correct as the other warnings are raised in union_serialize
.
mut selector: impl FnMut(&CombinedSerializer, &Extra) -> PyResult<S>, | ||
extra: &Extra, | ||
) -> PyResult<Option<S>> { | ||
if let Some(tag) = self.get_discriminator_value(value) { |
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.
Makes sure that we always try to get the tag by having the method call here 😉
CodSpeed Performance ReportMerging #1552 will not alter performanceComparing Summary
|
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.
Nice work, thanks for consolidating!
Change Summary
Fixes unintentional performance loss from #1538
At the same time I thought I would compress this down a bit further.
Related issue number
N/A
Checklist
pydantic-core
(except for expected changes)