-
-
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
When working on types, inference rather greedily widens #36713
Comments
Is #35504 relevant here? |
I think this one is different but I'm not sure |
master seems to infer the type of variables better, so it may not be that far from inferring the return type too:
master:
|
The problem is this function: Lines 204 to 208 in 7c0cb30
With sufficient knowledge about the parameters, it can be run at compile time (thanks to the @pure ). But otherwise, it can obviously at best be inferred as Type{<:Tuple} . (in fact, it's only inferred as Any , but that doesn't matter much.)
|
I'm not sure I understand...seems like Julia should have all the information it needs? |
Ah, sorry, that might ave been a bit terse. Note that Note that if the types were |
Oh I see, got it. Still seems like |
I guess, one would hope that anything infer-able for Tuples would also be infer-able for named tuples, and it infers fine with a tuple:
|
Am I correct in thinking that the real problem is that generated and pure functions can only be used by the compiler ahead of time if arguments are leaf-type, even if sufficient type information would be available otherwise? I could change the title if so. |
While that would be helpful in this specific case, one would also hope that e.g. In a first step, that would mean replacing the return Tuple{ntuple(n -> fieldtype(sym_in(names[n], bn) ? b : a, names[n]), Val(length(names)))...} results in |
Well, you've lost me again but I believe you |
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 |
Inference now is fine with this, and generates the optimal types
Note that because NamedTuple uses a lot of |
Running this code:
The returned value from inference is
NamedTuple{(:a, :b),_A} where _A<:Tuple
.I would expect it to be
NamedTuple{(:a, :b), T} where T <: Tuple{Union{Int, String}, Union{Int, String}}
.This would be useful for processing rows of a table.
The text was updated successfully, but these errors were encountered: