From e803d7800e9b630f532467aa69c3f1d85cba868e Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Wed, 19 Feb 2020 17:57:10 -0500 Subject: [PATCH] Documentation: Mention `Vararg{Any, N}` in the "Performance Tips" section of the manual (#34796) --- doc/src/manual/performance-tips.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/src/manual/performance-tips.md b/doc/src/manual/performance-tips.md index 31aee26a4b3a6..34b033dc5aae2 100644 --- a/doc/src/manual/performance-tips.md +++ b/doc/src/manual/performance-tips.md @@ -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