Skip to content

Commit

Permalink
Documentation: Mention Vararg{Any, N} in the "Performance Tips" sec…
Browse files Browse the repository at this point in the history
…tion of the manual (JuliaLang#34796)
  • Loading branch information
DilumAluthge authored and birm committed Feb 22, 2020
1 parent bb56288 commit f5383f8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/src/manual/performance-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,11 @@ but this will:
g_vararg(x::Vararg{Int, N}) where {N} = tuple(x...)
```

One only needs to introduce a single type parameter to force specialization, even if the other types are unconstrained. For example, this will also specialize, and is useful when the arguments are not all of the same type:
```julia
h_vararg(x::Vararg{Any, N}) where {N} = tuple(x...)
```

Note that [`@code_typed`](@ref) and friends will always show you specialized code, even if Julia
would not normally specialize that method call. You need to check the
[method internals](@ref ast-lowered-method) if you want to see whether specializations are generated
Expand Down

0 comments on commit f5383f8

Please sign in to comment.