-
-
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
RFC: Add @will_specialize
macro and will_specialize
function to InteractiveUtils
#33146
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.
This seems cool! I am not well-placed to review the implementation (sorry), but some thoughts on docs below :)
@will_specialize | ||
|
||
Evaluates the arguments to the function or macro call, determines their types, and calls | ||
[`will_specialize`](@ref) on the resulting expression. |
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.
I wonder if it is worth cross-referencing Base's at-specialize
/ at-nospecialize
for extra context?
e.g.
[`will_specialize`](@ref) on the resulting expression. | |
[`will_specialize`](@ref) on the resulting expression. | |
See also: [`specialize`](@ref), [`nospecialize`](@ref) |
(^ I think at-ref to Base function will "just work" but not 100% sure if this is the right suntax for it)
will_specialize(f, types) | ||
|
||
Returns `true` if the specialization on this method signature will be compiled | ||
into the cache for this method. |
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.
Perhaps worth making even more explicit that this means "Returns true
if the call will be specialized on all its arguments"?
I really like the explanation you gave in the opening post of the PR :)
Could some of the examples you give be included in the docstring (as doctests)?
@will_specialize
macro and will_specialize
function to InteractiveUtils
@will_specialize
macro and will_specialize
function to InteractiveUtils
This is a note to myself: This pull request only deals with positional arguments. We will need to also find a way to deal with inaccurate specialization on keyword arguments. |
…ill_specialize` function
@DilumAluthge Was this work continued or replaced elsewhere or did you decide to stop working on it? |
See also: #33142
This pull request adds the
InteractiveUtils.@will_specialize
macro and theInteractiveUtils.will_specialize
function.InteractiveUtils.@will_specialize f(x, y, z...)
returnstrue
if the call tof(x, y, z...)
will be fully specialized on its arguments, andfalse
otherwise.InteractiveUtils.will_specialize f(x, Tuple{R, S, T...}
returnstrue
if the call tof
with argument typesR, S, T...
will be fully specialized on its arguments, andfalse
otherwise.Examples
Motivation
As discussed in #23749, #32834, and #32817:
The
InteractiveUtils.@will_specialize
macro andInteractiveUtils.will_specialize
function introduced in this pull request provide a convenient way to find out whether or not Julia would normally specialize a given method call.