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
Add __eq__ and __ne__ to collections.abc.Sequence. #71989
Comments
Both Mapping and Set provide __eq__ and __ne__. Why not have Sequence do the same? |
Your implementation looks like it will make a Sequence equal to a list and a tuple, even though lists and tuples are never equal to each other. |
That's a really good point. Perhaps bring it up on ideas so that it can be discussed by more people? I don't know what the answer is. |
(there's already an open thread.) |
I was wondering the same thing recently, thanks for opening this issue. Here is my use case: I'm implementing a PersistentList, and I want it to be equal to a 'real' list, but not equal to a tuple. Frankly, I hadn't thought about the latter problem before this issue, so my __eq__ code in my concrete class is currently broken. I'll need to explicitly check for list subclasses and PersistentList subclasses. I'm not sure there's any way to "generalize" that. I presume that's why Sequence doesn't have the methods. The answer would seem to be to have explicit 'List' and 'Tuple' abcs. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: