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
You can break apart a NamedTuple into pairs and then rebuild it, which is very convenient, especially for programmatically building NamedTuples. However, constant propagation doesn't keep up through the process:
I watched the JuliaCon talk where @StefanKarpinski mentioned prioritizing making Julia faster for tabular data and I think solving this would be an important step
Tuple{::Pairs) looks suboptimal, only giving Tuple{Vararg{Pair{Int64, Pair{Symbol}}}} here. x -> (x...,) gives the slightly better NTuple{3, Pair{Int64, Pair{Symbol}}}, but still looses all const-ness.
Even if NamedTuple gets a const tuple of pairs, it still only infers as NamedTuple:
julia>foo() =NamedTuple((:a=>1, :b=>1.0, :c=>"1"))
foo (generic function with 1 method)
julia>@code_warntypefoo()
MethodInstance forfoo()
from foo() in Main at REPL[21]:1
Arguments
#self#::Core.Const(foo)
Body::NamedTuple1 ─ %1= (:a=>1)::Core.Const(:a=>1)
│ %2= (:b=>1.0)::Core.Const(:b=>1.0)
│ %3= (:c=>"1")::Core.PartialStruct(Pair{Symbol, String}, Any[Core.Const(:c), String])
│ %4= Core.tuple(%1, %2, %3)::Core.PartialStruct(Tuple{Pair{Symbol, Int64}, Pair{Symbol, Float64}, Pair{Symbol, String}}, Any[Core.Const(:a=>1), Core.Const(:b=>1.0), Core.PartialStruct(Pair{Symbol, String}, Any[Core.Const(:c), String])])
│ %5= Main.NamedTuple(%4)::NamedTuple
└── return%5
You can break apart a
NamedTuple
into pairs and then rebuild it, which is very convenient, especially for programmatically building NamedTuples. However, constant propagation doesn't keep up through the process:I wonder if it would be feasible for this to work in the first place, and if so, what the steps would be to getting there?
Ref #39910 (comment)
The text was updated successfully, but these errors were encountered: