Summary: Is there any performance benefit to annotating keyword arguments with types?
I understand that typed keyword arguments are as efficient as positional arguments. Is that correct?
But what are the performance characteristics of untyped keyword arguments compared to typed keyword arguments?
My understanding is that keyword arguments do not participate in dispatch. But do method calls with different typed keyword arguments get compiled separately? (as is the case for differently typed positional arguments). If so then does this mean that explicitly typing keyword args in function definition does not help performance?
The following is my attempt as investigate this - very likely flawed.
In any case, it seems all four invocations have the same benchmark time.
@code_warntype seems the same for f1, f2.
function f1(A; i::Int=1) return A[i] end function f2(A; i=1) return A[i] end using BenchmarkTools B = [1,2,3] @btime f1($B) @btime f2($B) @btime f1($B, i=2) @btime f2($B, i=2)