Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a promotion mechanism to choose array concatenation return type #18472

Closed
nalimilan opened this issue Sep 13, 2016 · 2 comments
Closed

Add a promotion mechanism to choose array concatenation return type #18472

nalimilan opened this issue Sep 13, 2016 · 2 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@nalimilan
Copy link
Member

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?

@mlubin
Copy link
Member

mlubin commented Sep 13, 2016

CC @madeleineudell

@JeffBezanson
Copy link
Member

Dup of #2326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

4 participants