<p dir="auto">This is a regression from 0.6.2 which affects DataFramesMeta (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="294832054" data-permission-text="Title is private" data-url="https://github.com/JuliaData/DataFramesMeta.jl/issues/88" data-hovercard-type="issue" data-hovercard-url="/JuliaData/DataFramesMeta.jl/issues/88/hovercard" href="https://github.com/JuliaData/DataFramesMeta.jl/issues/88">JuliaData/DataFramesMeta.jl#88</a>). Under some very particular circumstances, expression interpolation reverses the order of keys in a dictionary, compared with the order obtained in other places inside the same function. This is a problem when the function relies on the order of keys matching that of values (as with DataFrames macros).</p>
<p dir="auto">In the following example, <code class="notranslate">:a</code> appears before <code class="notranslate">:b</code> in the two first lines inside the quoted block, but that's the contrary for the third line.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function with_helper()
    membernames = Dict{Symbol,Int}(:a =&gt; 1, :b =&gt; 2)
    quote
        $(keys(membernames)...)
        $(map(key -&gt; :($key), keys(membernames))...)
        $(map(key -&gt; :(somedict[$key]), keys(membernames))...)
    end
end

julia&gt; with_helper()
quote
    #= REPL[1]:4 =#
    a
    b
    #= REPL[1]:5 =#
    a
    b
    #= REPL[1]:6 =#
    somedict[b]
    somedict[a]
end"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">with_helper</span>()
    membernames <span class="pl-k">=</span> <span class="pl-c1">Dict</span><span class="pl-c1">{Symbol,Int}</span>(<span class="pl-c1">:a</span> <span class="pl-k">=&gt;</span> <span class="pl-c1">1</span>, <span class="pl-c1">:b</span> <span class="pl-k">=&gt;</span> <span class="pl-c1">2</span>)
    <span class="pl-k">quote</span>
        <span class="pl-k">$</span>(<span class="pl-c1">keys</span>(membernames)<span class="pl-k">...</span>)
        <span class="pl-k">$</span>(<span class="pl-c1">map</span>(key <span class="pl-k">-&gt;</span> :(<span class="pl-k">$</span>key), <span class="pl-c1">keys</span>(membernames))<span class="pl-k">...</span>)
        <span class="pl-k">$</span>(<span class="pl-c1">map</span>(key <span class="pl-k">-&gt;</span> :(somedict[<span class="pl-k">$</span>key]), <span class="pl-c1">keys</span>(membernames))<span class="pl-k">...</span>)
    <span class="pl-k">end</span>
<span class="pl-k">end</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">with_helper</span>()
<span class="pl-k">quote</span>
    <span class="pl-c"><span class="pl-c">#=</span> REPL[1]:4 <span class="pl-c">=#</span></span>
    a
    b
    <span class="pl-c"><span class="pl-c">#=</span> REPL[1]:5 <span class="pl-c">=#</span></span>
    a
    b
    <span class="pl-c"><span class="pl-c">#=</span> REPL[1]:6 <span class="pl-c">=#</span></span>
    somedict[b]
    somedict[a]
<span class="pl-k">end</span></pre></div>
<p dir="auto">When computing the matrix product of a transposed real matrix with a complex matrix, I encountered a performance issue.</p>
<p dir="auto">Consider the following computations:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; A=randn(1000,1000);
julia&gt; B=randn(1000,1000);
julia&gt; Z=complex(randn(1000,1000),randn(1000,1000));
julia&gt; # pre-compiling
julia&gt; A'*B;
julia&gt; A'*Z;
julia&gt; complex(A'*real(Z),A'*imag(Z));
julia&gt; # timing
julia&gt; @time A'*B;
  0.025224 seconds (130 allocations: 7.637 MB)
julia&gt; @time A'*Z;
  1.899244 seconds (6 allocations: 15.259 MB)
julia&gt; @time complex(A'*real(Z),A'*imag(Z));
  0.062084 seconds (16 allocations: 45.777 MB, 8.73% gc time)"><pre class="notranslate"><code class="notranslate">julia&gt; A=randn(1000,1000);
julia&gt; B=randn(1000,1000);
julia&gt; Z=complex(randn(1000,1000),randn(1000,1000));
julia&gt; # pre-compiling
julia&gt; A'*B;
julia&gt; A'*Z;
julia&gt; complex(A'*real(Z),A'*imag(Z));
julia&gt; # timing
julia&gt; @time A'*B;
  0.025224 seconds (130 allocations: 7.637 MB)
julia&gt; @time A'*Z;
  1.899244 seconds (6 allocations: 15.259 MB)
julia&gt; @time complex(A'*real(Z),A'*imag(Z));
  0.062084 seconds (16 allocations: 45.777 MB, 8.73% gc time)
</code></pre></div>
<p dir="auto">The latter two computations are mathematically identical, however the last (more complex) expression is ~30x faster (and only ~2 times slower than the corresponding real-real product, as one would expect) than the straightforward expression <code class="notranslate">A'*Z</code>. Shouldn't both expressions be comparable in performance?</p>
<p dir="auto">I am running Julia 0.5.2 on Ubuntu 14.04.</p>
<p dir="auto">sysinfo() output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Julia Version 0.5.2
Commit f4c6c9d4bb (2017-05-06 16:34 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  BLAS: libopenblas (NO_LAPACK NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: liblapack.so.3
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)"><pre class="notranslate"><code class="notranslate">Julia Version 0.5.2
Commit f4c6c9d4bb (2017-05-06 16:34 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  BLAS: libopenblas (NO_LAPACK NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: liblapack.so.3
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
</code></pre></div>