[RFC] Replace Option<int> with optional::Optioned<int>
#2872
Labels
Comments
|
Maybe it needs a benchmark? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
Replace
Option<int>withoptional::Optioned<int>in native objects to save memory to enhance performance.Detailed Explanation
In many cases, our
usizemeansu63/u31rather thanu32/u64becausesys.maxsizeisisize::MAX.Unfortunately, we are not telling this to compiler very well.
For example,
Option<usize>forNoneoru63is a common type in RustPython. But its memory size if16rather than8https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cdbd4b4bcc01d81b57f8d9040901e107
By replacing it to
optional::Optioned<usize>, it will go back to8, the proper size of its actual representation.https://docs.rs/optional/
Drawbacks, Rationale, and Alternatives
Unresolved Questions
The text was updated successfully, but these errors were encountered: