title: Why is this Julia snippet so much slower than the Python equivalent? (with dictionaries)
body: <p>I have the following code in Python Jupyter:</p>
  <pre><code>n = 10**7
  d = {}
  
  %timeit for i in range(n): d[i] = i
  
  %timeit for i in range(n): _ = d[i]
  
  %timeit d[10]
  </code></pre>
  <p>with the following times:</p>
  <pre><code>763 ms ± 19.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
  692 ms ± 3.74 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
  39.5 ns ± 0.186 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
  </code></pre>
  <p>and this on Julia</p>
  <pre><code>using BenchmarkTools
  d = Dict{Int64, Int64}()
  n = 10^7
  r = 1:n
  
  @btime begin
      for i in r
          d[i] = i
      end
  end
      
  @btime begin
      for i in r
          _ = d[i]
      end
  end
  
  @btime d[10]
  </code></pre>
  <p>with times:</p>
  <pre><code>  2.951 s (29999490 allocations: 610.34 MiB)
    3.327 s (39998979 allocations: 762.92 MiB)
    20.163 ns (0 allocations: 0 bytes)
  </code></pre>
  <p>What I am not quite able to understand is why the Julia one seems to be so much slower in dictionary value assignation and retrieval in a loop (first two tests), but at the same time is so much faster in single key retrieval (last test). It seems to be 4 times slower when in a loop, but twice as fast if not in a loop. I'm new to Julia, so I am not sure if I am doing something un-optimal or if this is somehow expected.</p>