Skip to content

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

Merged
merged 4 commits into from
Oct 16, 2019
Merged

impl __sizeof__ for bytearray, int, list and str #1426

merged 4 commits into from
Oct 16, 2019

Conversation

RobertBerglund
Copy link
Contributor

work in progress

Copy link
Contributor

@windelbouwman windelbouwman left a 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?

@RobertBerglund
Copy link
Contributor Author

I planned on implementing the remaining sizeof methods as soon as I get some free time.
Thanks for the feedback !

@@ -566,6 +567,11 @@ impl PyInt {
!self.value.is_zero()
}

#[pymethod(name = "__sizeof__")]
fn sizeof(&self, _vm: &VirtualMachine) -> usize {
Copy link
Member

@coolreader18 coolreader18 Sep 28, 2019

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.

Copy link
Contributor Author

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 ?

@windelbouwman
Copy link
Contributor

@RobertBerglund I would suggest to merge this work so far, otherwise this branch will be in a more conflicted status.

@coolreader18 coolreader18 mentioned this pull request Oct 15, 2019
35 tasks
ashermancinelli added a commit to ashermancinelli/RustPython that referenced this pull request Oct 15, 2019
ashermancinelli added a commit to ashermancinelli/RustPython that referenced this pull request Oct 15, 2019
ashermancinelli added a commit to ashermancinelli/RustPython that referenced this pull request Oct 15, 2019
@youknowone youknowone merged commit 81302ce into RustPython:master Oct 16, 2019
coolreader18 added a commit that referenced this pull request Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants