RFC: lower T[a b; c d] to typed_hvcat(T, Val((2, 2)), a, b, c, d)#36719
RFC: lower T[a b; c d] to typed_hvcat(T, Val((2, 2)), a, b, c, d)#36719simeonschaub wants to merge 1 commit intoJuliaLang:masterfrom
Conversation
to explore the benefits of JuliaLang/julia#36719
|
It turns out, this actually benefits the |
|
How would this work if something in the hvcat expression isn’t scalar? I.e. concatenating subarrays? |
|
It still works: julia> Int[1:3 [3, 6, 4]; 7 [9]]
4×2 Matrix{Int64}:
1 3
2 6
3 4
7 9It's always this function that gets called after lowering and the tuple |
|
This seems interesting, and I think it could make sense because it exposes the syntax explicitly as a type which libraries can rely on rather than forcing them to rely on constant propagation of However I'm also not entirely sure this is necessary; as noted in JuliaArrays/StaticArrays.jl#811 (comment), |
|
I hope this can be avoided, since it will be harder on the compiler. |
to explore the benefits of JuliaLang/julia#36719
Please tell me if this is a dumb idea, but I'm doing some shenanigans with
Base.typed_hvcatin https://github.com/simeonschaub/CoolTensors.jl, where this significantly helps constant propagation and therefore type inference. This should be entirely non-breaking, because I added a fallback definition that falls back to calling the old methods. Is there reason to be concerned about latencies and invalidations here? From my qualitative testing, I didn't notice any difference and am inclined to say that this shouldn't make much of a difference for array constructors anyways, but perhaps it might be a good idea to add@nospecializeto the fallback methods?