Hi!
I am getting an allocation when using a keyword in the following MWE:
julia> function teste(a::AbstractVector{T}; b::Integer = 0, c::Integer = 0) where T
return a[1] + b + c
end
teste (generic function with 1 method)
julia> data = [1,2,3]
3-element Array{Int64,1}:
1
2
3
julia> teste(data); @time teste(data)
0.000003 seconds
1
julia> teste(data, b = 1); @time teste(data, b = 1)
0.000002 seconds (1 allocation: 16 bytes)
2
julia> teste(data, c = 1); @time teste(data, c = 1)
0.000002 seconds (1 allocation: 16 bytes)
2
julia> teste(data, b = 1, c = 1); @time teste(data, b = 1, c = 1)
0.000002 seconds (1 allocation: 32 bytes)
3
Is it expected? Why calling a function using a keyword argument do an allocation?
By the way, if a
is an Interger
instead of a Vector
, then I see no allocation at all.