I think the reason is that the compiler fails to infer the type of a for
test1 & test2. I guess if you write a::Vector{Int} = zeros(Int, dims...),
the situation would be quite different.
- Dahua
On Saturday, January 4, 2014 3:44:19 PM UTC-6, Milan Bouchet-Valat wrote:
>
> Hi!
>
> I'd like propose you a small game about performance. In the following
> gist, I provide three very similar short functions; the first one allocates
> much more memory and is much slower than the two others. Can someone find
> an explanation? ;-)
>
> https://gist.github.com/nalimilan/8261056
>
> The real-world scenario is again building a frequency table. I discovered
> that when doing a = zeros(Int, dims) I really had to make dim a tuple
> rather than an array, which forces me to use two versions of the same data,
> one in each type
>
> Thanks for the help!
>