Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add method for getting memory consumption of BigInt #98

@Askaholic

Description

@Askaholic

It would be nice to have a method for getting the memory consumption of BigInts and BigUInts. In particular this crate is being used by RustPython, and the python spec requires builtins to implement a __sizeof__ method that returns the amount of memory used by an object in bytes. This is quite easy to calculate using std::mem::size_of_val, unfortunately it requires a reference to the underlying data Vec, which of course is not exposed by the BigInt api.

My proposal is to either:

  1. Add a method for getting a reference to data or
  2. Add a method for getting the size of BigInt/BigUInt

I would prefer the first option because it will support a lot more unforseen use cases.

See the discussion at RustPython/RustPython#1172

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions