-
-
Notifications
You must be signed in to change notification settings - Fork 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
Fix 128bit support when deserializing to Rust types #1979
Fix 128bit support when deserializing to Rust types #1979
Conversation
@@ -2775,16 +2875,19 @@ where | |||
visitor.visit_unit() | |||
} | |||
|
|||
// FIXME: How to have different integer128 and not(integer128) versions? |
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.
How should I address separation of 128bit supported version of the code below and non-128bit version?
@dtolnay could you have a look at this PR?It should be quite obvious if I'm doing the right thing. Only thing I'm not sure about, is the one where I added fixme comment. I tested it against simd-json where it solved the related issue. |
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.
Thanks for the PR! @mikonieminen I am leaning toward not accepting this, since additions to Content tend to be extremely expensive to compile time. Basically this would cause ~25% increase in compile time of untagged enums and externally tagged enums due to the greater number of visitor methods instantiated when deserializing from Content, in service of a use case that is quite rare (most codebases do not use 128 bit integers at all, and of those the subset to use one inside untagged enums is even smaller) which is not clearly the right tradeoff.
@dtolnay thanks for the reply. Does this mean that you're planning to remove 128bit support completely from So in short, what would you say if 128bit integer support would be turned into a non-default feature instead of automatically enabling it if you have new enough Rust version? |
@dtolnay would it make things better if this would be behind a feature flag |
cc #1679 |
@dtolnay would it be sensible to use some better media where we could discuss this and other topics like What I'm worried is that arbitrary precision support would not perform that well compared to fixed 128 or 256 bit support and usually when (de)serializing your data, you already know if I would suggest that default implementation is 64 bit only, while 128 or 256 bit support (maybe even arbitrary precision) would be a feature that you need to enable explicitly. Any thoughts? |
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.
I'll go ahead and close this PR. Thanks anyway! I think the right fix here is going to be #1183 followed by using a JSON-specific type (serde_json::Value, serde_json::value::RawValue, or something like it) instead of Content
as the transient buffer when deserializing untagged or internally tagged enums from JSON.
This fixes support for 128bit values and it is tested currently with
simd-json
, because that's what I needed first and how to fixserde_json
was not right away obvious to me.This fixes #1719