-
-
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
Document type specialization #23471
Comments
Does that issue affect |
I didn't see the
and look at generated code for |
That makes sense. Can anyone please explain to me how |
Type stable means that the inference can know what the return (or other variable) type is (are). Specialize means the compiler generate code for a specific input. The latter requires the former but is not implied by it. We do more inference than specialization to avoid excess code generation. |
MyType{T} = Type{T}
MyType2 = Type
foo1(t::Type, x) = Nullable{t}(sin(x))
foo3(t::MyType, x) = Nullable{t}(sin(x))
foo4(t::MyType2, x) = Nullable{t}(sin(x))
@btime foo1(Float64, 2)
408.815 ns (2 allocations: 48 bytes)
@btime foo3(Float64, 2)
17.358 ns (0 allocations: 0 bytes)
@btime foo4(Float64, 2)
349.832 ns (2 allocations: 48 bytes)
MyType == MyType2 # true While I can see where these results are coming from, it's very subtle behavior, with a large performance impact. |
Don't you need a |
Same results. |
Oh yeah, it's only used in the function definition. |
Dup of #32834. |
On 0.6.0,
However, both functions are
@inferred
correctly, and have the same@code_llvm
. Why doesfoo1
allocate?Might be related to #19137
The text was updated successfully, but these errors were encountered: