-
Notifications
You must be signed in to change notification settings - Fork 1.3k
impl __sizeof__ for bytearray, int, list and str #1426
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
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.
This looks good to me. Do you already want to merge this, or develop it further?
I planned on implementing the remaining sizeof methods as soon as I get some free time. |
@@ -566,6 +567,11 @@ impl PyInt { | |||
!self.value.is_zero() | |||
} | |||
|
|||
#[pymethod(name = "__sizeof__")] | |||
fn sizeof(&self, _vm: &VirtualMachine) -> usize { |
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 use self.value.bits()
and then round up to the nearest u64
for this.
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.
something like (self.value.bits() as f64 / 8.).ceil() as usize
?
@RobertBerglund I would suggest to merge this work so far, otherwise this branch will be in a more conflicted status. |
`int.__sizeof__` from #1426
work in progress