On Tue, May 10, 2016 at 2:22 PM, <[email protected]> wrote: > Watch this. > > We define an array: > a = collect(-1:0.001:1) > > Then map something over the aforementioned array for the first time: > @time map(x->10^x, a) > # 0.049258 seconds > > Do it again so that we don't capture JIT compilation time:
This doesn't work > @time map(x->10^x, a) Since this is a different anonymous function. > # 0.048793 seconds -- didn't change much > > Now we assign the anonymous function to a variable: > f = x->10^x > > Then we map the variable over the array: > @time map(f, a) > # 0.047853 seconds > > Again so that we avoid JIT: It works this time > @time map(f, a) Since this is the same anonymous function > # 0.000386 seconds -- wow > > What is happening here? > Why does assigning an anonymous function to a variable makes the function > execution so much faster? > > > Yousef
