abisen

1 thought; 1 stream
last posted Oct. 13, 2016, 5:51 a.m.
0
Joined on Oct. 11, 2016, 2:45 p.m.
get recent cards as: atom

Optimal way of using simple map() is by avoiding to use lambda function. So for example

dbl(x)=x*2
arr=rand(1000)

non-optimal method is significantly more expensive.

julia> @time map(dbl, arr);
  0.000090 seconds (7 allocations: 8.125 KB)

and by avoiding the use of lambda you get

julia> @time map(x->dbl(x), arr);
  0.040455 seconds (13.77 k allocations: 632.087 KB)
1 thought
updated Oct. 13, 2016, 5:52 a.m.
1 thought
updated Oct. 13, 2016, 5:52 a.m.

Streams by this user that have been favorited by others.

No favorited streams yet.

rrees liked abisen's thought #10973 on JuliaLang
7 years, 6 months ago
1

Optimal way of using simple map() is by avoiding to use lambda function. So for example

dbl(x)=x*2
arr=rand(1000)

non-optimal method is significantly more expensive.

julia> @time map(dbl, arr);
  0.000090 seconds (7 allocations: 8.125 KB)

and by avoiding the use of lambda you get

julia> @time map(x->dbl(x), arr);
  0.040455 seconds (13.77 k allocations: 632.087 KB)

Thoughts by this user that have been liked by others.

1

Optimal way of using simple map() is by avoiding to use lambda function. So for example

dbl(x)=x*2
arr=rand(1000)

non-optimal method is significantly more expensive.

julia> @time map(dbl, arr);
  0.000090 seconds (7 allocations: 8.125 KB)

and by avoiding the use of lambda you get

julia> @time map(x->dbl(x), arr);
  0.040455 seconds (13.77 k allocations: 632.087 KB)