Does Dict(::Dict)
copy only because the method is the vehicle for implementing copy(d::Dict)
?
Fallback for T(::T)
:
(::Type{T})(arg) where {T} = convert(T, arg)::T # Hidden from the REPL.
usually leads to no copying:
julia> x = "a"; x === typeof(x)(x)
true
julia> x = (1,"a"); x === typeof(x)(x)
true
julia> x = Ref("a"); x === Ref(x)
true
julia> x = ["a"]; x === typeof(x)(x)
true
julia> x = Dict(1 => "a"); x === typeof(x)(x)
false
I’m having trouble drawing a distinction.
Dict(d::Dict) behavior originally implemented here.