Perhaps I’m wrong, but I think there was a time when defining functions like f(x::Real) = ...
was discouraged because of performance reasons. Instead, people were told to use f(x::T) where {T <: Real} = ...
. Yet, I see the use of the former form in some packages that should be very performant. Are these two forms now similar in performance?
f(x::Real)
hasn’t had any problems since at least 0.6. The place where specific type annotations matter is in struct definitions. Functions specialize automatically on the types of their inputs.
1 Like
I guess my last big project in Julia was with version 0.4-0.5. Great to know that there is no need to worry about those annotations now.