-
Notifications
You must be signed in to change notification settings - Fork 293
Fix scientific floats #774
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
@@ -146,7 +146,7 @@ impl<'de> Deserialize<'de> for JsonInput { | |||
|
|||
if let JsonInput::String(s) = &first_value { | |||
// Normalize the string to either an int or float | |||
let normalized = if s.contains('.') { | |||
let normalized = if s.contains('.') || s.contains('e') { |
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.
Maybe there's a better way to do this check, or maybe there's a way to better-infer from serde_json itself that the value should be a number..? @davidhewitt @samuelcolvin @adriangb
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.
Okay after some unnecessarily thorough investigation (assisted by @adriangb, thanks) I'm pretty confident this approach is sufficiently optimized
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #774 +/- ##
=======================================
Coverage 93.67% 93.67%
=======================================
Files 99 99
Lines 14290 14290
Branches 25 25
=======================================
Hits 13386 13386
Misses 898 898
Partials 6 6
Continue to review full report in Codecov by Sentry.
|
CodSpeed Performance ReportMerging #774 will not alter performanceComparing Summary
|
Closes pydantic/pydantic#6684