classification
Title: Add __eq__ and __ne__ to collections.abc.Sequence.
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: NeilGirdhar, martin.panter, r.david.murray
Priority: normal Keywords: patch

Created on 2016-08-19 12:42 by NeilGirdhar, last changed 2016-08-19 18:31 by gvanrossum. This issue is now closed.

Files
File name Uploaded Description Edit
abc_eq.diff NeilGirdhar, 2016-08-19 13:14 review
Messages (5)
msg273114 - (view) Author: Neil Girdhar (NeilGirdhar) * Date: 2016-08-19 12:42
Both Mapping and Set provide __eq__ and __ne__.  Why not have Sequence do the same?
msg273119 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-08-19 13:32
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.
msg273121 - (view) Author: Neil Girdhar (NeilGirdhar) * Date: 2016-08-19 13:34
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.
msg273122 - (view) Author: Neil Girdhar (NeilGirdhar) * Date: 2016-08-19 13:34
(there's already an open thread.)
msg273135 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-08-19 15:19
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.
History
Date User Action Args
2016-08-19 18:31:18gvanrossumsetstatus: open -> closed
resolution: rejected
stage: resolved
2016-08-19 15:19:17r.david.murraysetnosy: + r.david.murray
messages: + msg273135
2016-08-19 13:34:58NeilGirdharsetmessages: + msg273122
2016-08-19 13:34:27NeilGirdharsetmessages: + msg273121
2016-08-19 13:32:36martin.pantersettype: enhancement

messages: + msg273119
nosy: + martin.panter
2016-08-19 13:14:26NeilGirdharsetfiles: + abc_eq.diff
keywords: + patch
2016-08-19 12:42:54NeilGirdharsetcomponents: + Library (Lib)
versions: + Python 3.6
2016-08-19 12:42:24NeilGirdharcreate