I cannot replicate this on master with the following code. The two functions perform very similarly.
function dict_performance()
n = 100_000_000
x = Dict{Int,Int}()
sizehint!(x, n)
for i in 1:n
x[i] = i
end
end
function dict_performance2()
n = 100_000_000
x = Dict{Int,Int}()
sizehint!(x, n)
for i in 1:n
get!(x, i, i)
end
end
using BenchmarkTools
@btime dict_performance()
@btime dict_performance2()
OTOH, it seems that the total time/number of iterations ratio gets worse as the number of unique entries gets larger. More systematic benchmarking would be needed to find out whether that’s a real problem or not.
@phrmoy Does storing 100M unique values correspond to your actual use case? It could be that Julia performs as well as Python for smaller sizes.