Convert tuple to array

julia> using BenchmarkTools

julia> a = (1, 2, 3)
(1,2,3)

julia> a_large = ([rand(1:5) for i in 1:50]...)
(2,1,2,1,2,1,3,5,1,1,5,4,1,5,3,4,2,2,3,3,2,3,5,1,4,4,5,2,2,3,1,2,5,2,1,2,3,2,2,4,1,3,1,4,2,3,5,2,4,1)

julia> f_splat(a)   = [a...];

julia> f_collect(a) = collect(a);

julia> f_comp(a)    = [i for i in a];

julia> @btime f_splat($a);
  35.741 ns (1 allocation: 112 bytes)

julia> @btime f_collect($a);
  31.897 ns (2 allocations: 128 bytes)

julia> @btime f_comp($a);
  26.184 ns (1 allocation: 112 bytes)

julia> @btime f_splat($a_large);
  774.571 ns (2 allocations: 992 bytes)

julia> @btime f_collect($a_large);
  82.332 ns (2 allocations: 560 bytes)

julia> @btime f_comp($a_large);
  88.702 ns (1 allocation: 544 bytes)
21 Likes