You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I couldn't confirm this in the source code, so I asked on discourse where a benchmark showed fewer allocations when manually calling sizehint! than when using a generator expression.
using BenchmarkTools
println("Implicit:")
@btimebegin
dict =Dict(string(i) =>sind(i) for i =0:5:360)
endprintln("Explicit:")
@btimebegin
dict =Dict{String, Int}()
sizehint!(dict, 360÷5)
for i in0:5:360
dict[string(i)] = i
endend
If you want to compare the effect of the sizehint! shouldn't you just measure your explicit one but without the sizehint! call? Otherwise, other differences in the constructor for dictionaires from generators will pollute the result.
I mean, not really, as this is an issue, which that PR can close! it's always nice for a PR author to close an issue, so I suggest to keep this open, now that it has been created :)
Dictionaries can be created from generator expressions, but don't seem to use
sizehint!
. This could give better performance.I couldn't confirm this in the source code, so I asked on discourse where a benchmark showed fewer allocations when manually calling
sizehint!
than when using a generator expression.Results in
The text was updated successfully, but these errors were encountered: