I've written an implementation of vcat for the special case of mixed 
scalar-vector parameters (e.g. vcat(1,[2,3],4)) using generated functions. 
I get a speed increase of a factor 70 and memory usage reduction by a 
factor 10. It also makes this special case of vcat type stable (e.g. the 
inferred type is Array{Int64,1} rather than Any for vcat(1,[2,3],4)). See
https://gist.github.com/afniedermayer/947faadd362778d088d7

I'd like to make a pull request (or at least provide a package that 
overloads vcat to start with), but I haven't figured out how to dispatch on 
mixed scalar-vector parameters.
Base.vcat{T}(x::Union{T,Array{T,1}}...) = mixed_vcat(x...)


doesn't work, see
https://groups.google.com/forum/#!topic/julia-users/NCfxu7_9VR0

Is there a way to dispatch on mixed scalar-vector parameters (besides 
dispatching in the generated function)?

Reply via email to