For some reason, the init
slows it down quite a bit:
julia> @btime reduce(vcat, $v, init=Int[]);
23.151 μs (101 allocations: 210.23 KiB)
julia> @btime reduce(vcat, $v);
962.444 ns (2 allocations: 5.12 KiB)
There is a related open issue for mapreduce
(#31137) — it seems like we didn’t optimize a sufficiently low-level method of reduce
.