Re: [julia-users] Concatenation without splatting

2015-11-23 Thread Dan
Using `append!` instead of `push!` and letting efficient dynamic reallocation of vector do the resizing: function vcat_nosplat2a(y) result = Array(eltype(y[1]), 0) for a in y append!(result, a) end result end (@benchmark shows way less allocations and 2-3x time) BTW the

Re: [julia-users] Concatenation without splatting

2015-11-23 Thread Tomas Lycken
That doesn’t quite seem to do what you want, Mauro: julia> arr_of_arr = Vector{Int}[[1],[2,3],[4,5]] 3-element Array{Array{Int64,1},1}: [1] [2,3] [4,5] julia> vcat_nosplat(y) = eltype(y[1])[el[1] for el in y] vcat_nosplat (generic function with 1 method) julia> vcat_nosplat(arr_of_arr)

Re: [julia-users] Concatenation without splatting

2015-11-23 Thread Tomas Lycken
Using append! is definitely an improvement, thanks! The reason I included the sizehint! call was that this resizes the vector *once*, and without requiring to copy any elements, and I assumed those saved copies would quickly win over having to iterate the collection an extra time to get the

Re: [julia-users] Concatenation without splatting

2015-11-23 Thread Mauro
> That doesn’t quite seem to do what you want, Mauro: Yes, you're right, sorry for the noise! > julia> arr_of_arr = Vector{Int}[[1],[2,3],[4,5]] > 3-element Array{Array{Int64,1},1}: > [1] > [2,3] > [4,5] > > julia> vcat_nosplat(y) = eltype(y[1])[el[1] for el in y] > vcat_nosplat (generic

[julia-users] Concatenation without splatting

2015-11-22 Thread Cedric St-Jean
I have a big vector of vectors. Is there any way to vcat/hcat them without splatting? arr_of_arr = Vector[[1],[2,3],[4,5]] vcat(arr_of_arr...) I'm asking because splatting big arrays is a performance issue (and IIRC it blows the stack at some point).

Re: [julia-users] Concatenation without splatting

2015-11-22 Thread Mauro
In ODE.jl, I've used vcat_nosplat(y) = eltype(y[1])[el[1] for el in y] # Does vcat(y...) without the splatting I think the eltype might not be needed. There may be better ways though. On Sun, 2015-11-22 at 14:04, Cedric St-Jean wrote: > I have a big vector of