From the docs my understanding is that Array
s of optionally missing
values actually store two arrays, one for the data and one to store whether or not the value is missing
. If I've got that right, I don't understand why sizeof()
says these are the same size in memory:
julia> x = rand(UInt16, 2, 2)
2×2 Matrix{UInt16}:
61892 4489
19311 27433
julia> y = Array{Union{Missing, UInt16}}(missing, 2, 2)
2×2 Matrix{Union{Missing, UInt16}}:
missing missing
missing missing
julia> sizeof(x)
8
julia> sizeof(y)
8
Shouldn't sizeof(y) == 12
? 8 bytes for the data plus 4 bytes for the mask.
Ah hah, turns out I should be using Base.summarysize()
: https://discourse.julialang.org/t/sizeof-vector-union-missing-t-and-hypothetical-size/15271/14
julia> Base.summarysize(x)
48
julia> Base.summarysize(y)
52
Last updated: Nov 06 2024 at 04:40 UTC