You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, AbstractArray concatenation methods like vcat and hcat call similar on the first argument to choose the type of the array to return. This is quite arbitrary, and forces custom types to define methods which first convert their arguments before passing them to the AbstractArray methods. This isn't efficient as it creates unnecessary copies. Examples include sparse matrices (#17685) and PooledDataArrays/CategoricalArrays (JuliaStats/DataArrays.jl#213), where the integer size of the underlying storage depends on the one used by the inputs.
I suggest we use the promotion mechanism to choose the return type instead. Custom array types would just have to define a function to indicate which type should "win". We could still keep the fallback on the first argument to ease the transition. The question is, can we use promote for that, or do we need a different approach?
The text was updated successfully, but these errors were encountered:
Currently,
AbstractArray
concatenation methods likevcat
andhcat
callsimilar
on the first argument to choose the type of the array to return. This is quite arbitrary, and forces custom types to define methods which first convert their arguments before passing them to theAbstractArray
methods. This isn't efficient as it creates unnecessary copies. Examples include sparse matrices (#17685) and PooledDataArrays/CategoricalArrays (JuliaStats/DataArrays.jl#213), where the integer size of the underlying storage depends on the one used by the inputs.I suggest we use the promotion mechanism to choose the return type instead. Custom array types would just have to define a function to indicate which type should "win". We could still keep the fallback on the first argument to ease the transition. The question is, can we use
promote
for that, or do we need a different approach?The text was updated successfully, but these errors were encountered: