Skip to content

improve Base.summarysize for BigInt #44780

@MHellmund

Description

@MHellmund
julia> versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

julia> b=big(17)^300;

julia> Base.summarysize(b)
16

According to the discussion https://discourse.julialang.org/t/how-do-i-get-the-memory-size-of-a-bigint/ ,
the b.alloc field contains the number of limbs allocated by GMP.

Base.summarysize(b) should return this:

julia> div(b.alloc * Base.GMP.BITS_PER_LIMB,   8)
184

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIndicates a good issue for first-time contributors to Julia

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions