-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize copy!(::Dict, ::Dict) #34101
Conversation
Does the case 2) assume that |
Do you have an example where |
Why would So to answer your question: julia> struct A
end
julia> struct B
end
julia> Base.convert(::A, ::Type{B}) = B()
julia> a = A(); convert(a, B) !== A
true There are also methods of the form |
When
Besides the reversed order of the argument, yes there is no problem with that. My remark was based on the |
Correct, for example |
Sorry, you are right. So in the signature of the second case, either |
Yes. Even without considering the abstract/non-abstract distinction, if |
Seems to have broken CI. I'm gonna suggest a revert until this can be investigated. |
Sounds good to me. The CI was all green as of the last commit so I thought it was good to go. |
This PR implements two optimizations for
copy!(dst::Dict, src::Dict)
. This came up in another PR for implementingsetindex
forDict
: #33495 (comment)Case 1:
copy!(dst::D, src::D) where {D <: Dict}
This is a straightforward case where you can copy properties as-is:
prints
in Julia 1.3.
Case 2:
copy!(dst::Dict{Kd}, src::Dict{Ks}) where {Ks,Kd>:Ks}
This is the case you don't need to re-compute hashes:
This prints
in Julia 1.3.