In performance tips, it says
Essentially, Val{T}
works only when T
is either hard-coded (Val{3}
) or already specified in the type-domain.
Suppose I have
ff(::Type{Val{1}}) = 1
I guess the following is on a slower route.
x = 1
a = ff(::Type{Val{x}})
And maybe this one can be determined in compile time
const y = 1
a = ff(::Type{Val{y}})
How can I tell if it is fast or slow? @code_warntype doesn't tell the difference here?