Skip to content

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

Merged
youknowone merged 4 commits into
RustPython:masterfrom
RobertBerglund:sizeof
Oct 16, 2019
Merged

youknowone merged 4 commits into
RustPython:masterfrom
RobertBerglund:sizeof

Conversation

@RobertBerglund

Copy link
Copy Markdown
Contributor

work in progress

@windelbouwman windelbouwman left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

Comment thread vm/src/obj/objstr.rs Resolved
Comment thread vm/src/obj/objint.rs
}

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

@coolreader18 coolreader18 Sep 28, 2019 •

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
33 of 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