Was just curious if there was actually a difference in some way between these two ways of defining a method with parametric types.
function f1(x::Vector{<:Real})
# Stuff
end
function f2(x::Vector{T}) where T <: Real
# Stuff
end
Gave a quick try where i set # Stuff to be first(x) and looked at @code_native which seemed exactly the same, but maybe that was just so simple so it turned out the same?
The difference lies in T - in the first version, you don’t have access to the type parameter itself (should you need it anywhere and the type given doesn’t have a convenient eltype defined) whereas the latter gives you access to the actual type as T.
Performance and compile wise they are the same, if you don’t need access to T directly.
Okay, exactly what I was wondering. I understood that access to T was one thing, but didn’t know if there were some additional compiler things or similar that made them different. Thanks!