# Parametric type signature in methods, any actual difference?

**URL:** <https://discourse.julialang.org/t/parametric-type-signature-in-methods-any-actual-difference/67663>\
**Category:** General Usage\
**Created:** [September 3, 2021, 6:43pm UTC](https://discourse.julialang.org/t/parametric-type-signature-in-methods-any-actual-difference/67663 "2021-09-03T18:43:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [September 3, 2021, 6:43pm UTC](https://discourse.julialang.org/t/parametric-type-signature-in-methods-any-actual-difference/67663/1 "2021-09-03T18:43:21Z")

</div>

Was just curious if there was actually a difference in some way between these two ways of defining a method with parametric types.

```julia
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?

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [September 3, 2021, 6:46pm UTC](https://discourse.julialang.org/t/parametric-type-signature-in-methods-any-actual-difference/67663/2 "2021-09-03T18:46:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [September 3, 2021, 9:26pm UTC](https://discourse.julialang.org/t/parametric-type-signature-in-methods-any-actual-difference/67663/3 "2021-09-03T21:26:13Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [September 3, 2021, 9:59pm UTC](https://discourse.julialang.org/t/parametric-type-signature-in-methods-any-actual-difference/67663/4 "2021-09-03T21:59:45Z")

</div>

There are a few cases in which the type parameter triggers a heuristic that tells Julia to specialize on the argument when it might not otherwise: [https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing](https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing) (doesn’t matter for `Vector` though).
