Issue 27802: Add eq and ne to collections.abc.Sequence. (original) (raw)

Created on 2016-08-19 12:42 by NeilGirdhar, last changed 2022-04-11 14:58 by admin. 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
2022-04-11 14:58:35 admin set github: 71989
2016-08-19 18:31:18 gvanrossum set status: open -> closedresolution: rejectedstage: resolved
2016-08-19 15:19:17 r.david.murray set nosy: + r.david.murraymessages: +
2016-08-19 13:34:58 NeilGirdhar set messages: +
2016-08-19 13:34:27 NeilGirdhar set messages: +
2016-08-19 13:32:36 martin.panter set type: enhancementmessages: + nosy: + martin.panter
2016-08-19 13:14:26 NeilGirdhar set files: + abc_eq.diffkeywords: + patch
2016-08-19 12:42:54 NeilGirdhar set components: + Library (Lib)versions: + Python 3.6
2016-08-19 12:42:24 NeilGirdhar create