-
-
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
@nospecialize
for identity
#44929
@nospecialize
for identity
#44929
Conversation
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.
We generally don't need to add @nospecialize
annotation if a generic function only contains a single method (and identity
will rarely be extended), but approved nevertheless as it doesn't hurt anything anyway.
I know there's a point where specialization doesn't occur, but I figure that we never wanted it to specialize and that even this was more than we wanted: julia> using MethodAnalysis
julia> using StaticArrays
julia> length(methodinstances(identity))
18
julia> identity(SVector(1, 2, 3));
julia> length(methodinstances(identity))
19
julia> foo(x) = identity(x)
foo (generic function with 1 method)
julia> foo(SVector(1, 2, 3, 4));
julia> length(methodinstances(identity))
20
|
Please note that |
The goal here was just to avoid codegen. I'm assuming that if this made it so we couldn't even infer what type |
"codegen" would be avoided even as is assuming the method body of |
I was considering additional method instances code generation (which I can see being considered an overgeneralization). Wouldn't we want to avoid generating those addition methods? |
It's simply that that information was used for Julia-level inference but it doesn't necessarily imply whole codegen process. |
Gotcha. Thanks for the clarification. |
No description provided.