-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix reduce(vcat,...) type inference (#40277) #40294
Conversation
This may be a stupid question, but why does I realize |
Not a stupid question at all; they should be the same. Maybe due to #35800. |
I've had to work around quite a few type-inference issues and there are a number of rules of thumbs I've picked up:
mapplus() = 0
mapplus(x, y...) = f(x) + mapplus(x, y...) |
I added an extra test that was reported from that issue |
@@ -1490,7 +1490,7 @@ AbstractVecOrTuple{T} = Union{AbstractVector{<:T}, Tuple{Vararg{T}}} | |||
|
|||
_typed_vcat_similar(V, ::Type{T}, n) where T = similar(V[1], T, n) | |||
_typed_vcat(::Type{T}, V::AbstractVecOrTuple{AbstractVector}) where T = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this change just for V::Tuple
and keep using mapreduce
for V::AbstractVector
, since in that case, it is probably beneficial to avoid the extra allocation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since vcat
itself is allocating I don't think this will make any noticeable difference, but it's easy to add if there's a good argument for why it's still needed.
Fixes #40277