Type stable Dict to hold Array{Float64, N} with variable N


#1

Is there any nice way to make such Dict type stable (where N might vary in different dict entries)?

Perhaps annotating when accessing some field (which I always know the size)

Or have a dict of Tuple(Vector{Float64},Vector{UInt32}) the second vector could keep count of dim sizes so that I can use ind2sub/sub2ind. This looks very messy and possibly inefficient…

thanks


#2

Annotating when accessing seems like a good idea (see: https://docs.julialang.org/en/latest/manual/performance-tips/#Annotate-values-taken-from-untyped-locations-1 ) .

But if you have a Dict with heterogeneous types, and you know the type of each field, then maybe a struct would be a better solution?