-
-
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
Get rid of special-casing of ranges in == and isequal() for AbstractArrays #16364
Comments
Ah, funny how I keep bumping into this issue without remembering... :-) Anyway, should we reopen one of the older issues about hashing ranges? This looks like a significant inconsistency in the language to me (and equality is already complex to master without it...). |
The concern is that it's an unsolvable problem, in which case reopening the issue won't help. |
Well, a few ideas were advanced here: #12226 (comment) It would be really sad that |
👍 Skip the discussion, go straight for the PR, then 😄. EDIT: meaning, fix the hashing algorithm so you get the best of all worlds. |
I didn't expect I would be able to do something about it, but it might be easier than I/we thought. Please comment on #16401. |
I rather suspect this is not going to happen in 0.6. |
Note that this is also not breaking – it's technically an optimization. |
You mean that we should make ranges and arrays hash equal by iterating over all of their elements, and try to optimize this later? |
Ah yes, I thought that was what we were already doing, actually! |
I kind of suspect that hashing ranges is not all that common, tbh. |
Yes, that's also my opinion. |
So should we squeeze the breaking portion of this into 0.6? It's a very easy change to make — just delete some code and fix a few tests. But changing the algorithmic complexity of Or we could alternatively add a depwarn for |
I'd vote for leaving this alone until we have a real plan for this. |
The
AbstractArray
default==
operator special-cases ranges:isequal
is defined in the same way.This is obviously not great. A new array type is considered as equal to a standard
Array
if their elements are all equal, but it is considered as different from a range containing the same elements. This inconsistency is visible even inside Base:So it's not clear whether two
AbstractArrays
need to be of the same type or not to be==
. I can see two consistent solutions:true
when elements are equal)if isa(A,Range) != isa(B,Range)
totypeof(A) !== typeof(B)
The second choice would clearly be much more disruptive than the first, and it would make
==
almost useless for arrays.The text was updated successfully, but these errors were encountered: