Dict loaded from jld file very long time... Why 22 seconds?

The Dict{K,V} notation means its keys have type K and its values have type V. In your slow example, Dict{Int64,Any}, the keys are Int64 but there is no available type information about the values (hence they are recorded as the Any type). It may perform faster if, instead of Any, the values are all of the same concrete type and this is known to the compiler. Notice that’s what happened in your fast-performing example Dict{Int64,Float64}, all the values were guaranteed to be of the same type Float64. This situation is called “strictly-typed”, unlike the case where values have Any type. Having strict type information can allow Julia to make significant optimisations.

1 Like