[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
usize
meansu63
/u31
rather thanu32
/u64
becausesys.maxsize
isisize::MAX
.Unfortunately, we are not telling this to compiler very well.
For example,
Option<usize>
forNone
oru63
is a common type in RustPython. But its memory size if16
rather than8
https://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: