-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
deprecate some copy! methods #24808
deprecate some copy! methods #24808
Conversation
Thanks. Completely agree on sets and associative. But it seems ok to me to use |
right, and I don't have a strong opinion about it personally. Then I see two options for the current 2-arg |
There are already many |
I think the best way to move forward here is to do the set and associative part immediately to make sure that gets in, while the |
Some observations on the 2 argument
I wouldn't mind if this requires a more specific signature.
(Disclaimer, I'm biased by the fact that about 100% of my use of |
In my opinion, |
@GunnarFarneback For your first two points I agree (assuming in point 2 you also mean "same size"). I agree that renaming to |
Agreed @andreasnoack. Even if we can't get rid of [6] copy!(dest::Array{T,N} where N, doffs::Integer, src::Array{T,N} where N, soffs::Integer, n::Integer) where T in Base at array.jl:202
[7] copy!(dest::Array{T,N} where N, src::Array{T,N} where N) where T in Base at array.jl:210
[9] copy!(dest::AbstractArray, dstart::Integer, src::AbstractArray) in Base at abstractarray.jl:674
[10] copy!(dest::AbstractArray, dstart::Integer, src::AbstractArray, sstart::Integer) in Base at abstractarray.jl:678
[11] copy!(dest::AbstractArray, dstart::Integer, src::AbstractArray, sstart::Integer, n::Integer) in Base at abstractarray.jl:686
[12] copy!(dest::AbstractArray, dstart::Integer, src) in Base at abstractarray.jl:582
[13] copy!(dest::AbstractArray, dstart::Integer, src, sstart::Integer) in Base at abstractarray.jl:592
[14] copy!(dest::AbstractArray, dstart::Integer, src, sstart::Integer, n::Integer) in Base at abstractarray.jl:620
[15] copy!(B::Union{AbstractArray{R,1}, AbstractArray{R,2}}, ir_dest::AbstractRange{Int64}, jr_dest::AbstractRange{Int64}, A::Union{AbstractArray{S,1}, AbstractArray{S,2}}, ir_src::AbstractRange{Int64}, jr_src::AbstractRange{Int64}) where {R, S} in Base at abstractarray.jl:704 |
Personally, it doesn't much bother me that |
As a datapoint, we have this definition in a package:
|
For object
I'm not against having something useful, but at least for the 2-arg methods
I've needed that, both at the REPL and in libraries, and examples of such use case can be found in the diff of this PR, look for "resize!". I think it's even possible that in base, |
Proposal: rename |
Another point: I think the non-resizing operation is not particularly useful and can easily lead to errors. I think that would better be written as a |
I agree that most of the objectionable |
|
It occurs to me that the definition of |
One point raised in triage is that these methods don't actually violate the principle that |
No one objects to deprecating the dict methods that violate the above principle, so we should definitely go ahead with that part of this. |
Triage decision: call to split the |
5bbdfb6
to
8ec136b
Compare
When the deprecation gets lifted, they will be re-enabled with a new meaning.
8ec136b
to
b35282b
Compare
I'm confident that the CI will pass this time, so will merge when it gets green (merges conflicts arise very fast). Note that I also renamed What would be the plan forward? can we introduce the new versions of |
This seems like a good idea to me. It'll let us get the work done and merged, and just leave us with a minor cleanup item (sed renaming) to do later, rather than delaying the whole thing to do at once. |
I assume you're talking about the places where the signatures of |
Yes, and for now we gave a meaning of |
Sure, why not. Let's have a |
The |
Sure, that seems like a good idea. It's a good way to signal it to people using it. |
Is there no way to make |
It seems that would entail patching the functions to check if the sizes agree, which is a no-go, at least with such short delay. This PR currently is a careful search-and-replace, checking that we replace only the cases which need to be, it's already some work. But to go through all the methods one-by-one (most of which I'm not familiar with) and thinking how to make it more hybrid is simply impossible for me. That's why I said re-introducing the correct |
Ah sorry, I read a bit too fast, you proposed only for |
I'm not quite following here. Why would people who are only using |
But can it? I really lack sleep, so I may not think well right now, but imagine someone using |
Yes, I think the best we can do here is print a warning even in the same-size case but indicating that they need to choose between using |
Are you fine that I merge this one as is when CI is green, and that I introduce |
Yes, go for it. All the packages are broken on master now anyway 😅 |
All green :) It was worth waiting! |
When the deprecation gets lifted, they will be re-enabled with a new meaning.
Apologies for this disruptive change. This is an attempt to make
copy!
more consistent. We havecopy
, which unambiguously creates a new object equal to its argument. In my opinion, the current version ofcopy!
conflates different meanings:copy
(it's the case for only fery few types in base, includingBitSet
andMersenneTwister
)AbstractSet
it's aunion!
, i.e. adding elements from a collection to anotherAssociative
, it's a kind ofmerge!
, which accepts any iterable (actually, 3 & 4 share the same implementation: reduce ofpush!
).For example, 1) and 3) lead to this horror:
Another usability problem is that in many cases, to
copy!(dst, src)
an array into another one, the user has to first manuallyresize!
the destination array to the source's size before being allowed tocopy!
(I didn't count, but this accounts for a big proportion of uses ofcopy!
in base).So this PR does the following:
copy!
as point 1) abovecopy!
tomemcopy!
(with deprecation)copy!
forAbstractSet
andAssociative
, as the replacement is straighforward.In a subsequent version of Julia (would be great for 1.0, but I don't think that the policy allows it),
copy!
can be re-introduced to do the "sane" thing, while keeping the more specificmemcopy!
for array work. Another possibility (which doesn't have my preference) would be to renamememcopy!
tocopy!
, but to change the meaning of the 2-arg version so thatresize!
happens automatically (in this case, we could keep the 3+ argcopy
methods as is without deprecating them in the first place).If this change is accepted, let's bikeshed!
memcopy!
vs.rawcopy
vs. ?