Skip to content
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

Closed
NeilGirdhar mannequin opened this issue Aug 19, 2016 · 5 comments
Closed

Add __eq__ and __ne__ to collections.abc.Sequence. #71989

NeilGirdhar mannequin opened this issue Aug 19, 2016 · 5 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@NeilGirdhar
Copy link
Mannequin

NeilGirdhar mannequin commented Aug 19, 2016

BPO 27802
Nosy @bitdancer, @vadmium, @NeilGirdhar
Files
  • abc_eq.diff
  • 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:

    assignee = None
    closed_at = <Date 2016-08-19.18:31:18.103>
    created_at = <Date 2016-08-19.12:42:24.855>
    labels = ['type-feature', 'library']
    title = 'Add __eq__ and __ne__ to collections.abc.Sequence.'
    updated_at = <Date 2016-08-19.18:31:18.102>
    user = 'https://github.com/NeilGirdhar'

    bugs.python.org fields:

    activity = <Date 2016-08-19.18:31:18.102>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-08-19.18:31:18.103>
    closer = 'gvanrossum'
    components = ['Library (Lib)']
    creation = <Date 2016-08-19.12:42:24.855>
    creator = 'NeilGirdhar'
    dependencies = []
    files = ['44151']
    hgrepos = []
    issue_num = 27802
    keywords = ['patch']
    message_count = 5.0
    messages = ['273114', '273119', '273121', '273122', '273135']
    nosy_count = 3.0
    nosy_names = ['r.david.murray', 'martin.panter', 'NeilGirdhar']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue27802'
    versions = ['Python 3.6']

    @NeilGirdhar
    Copy link
    Mannequin Author

    NeilGirdhar mannequin commented Aug 19, 2016

    Both Mapping and Set provide __eq__ and __ne__. Why not have Sequence do the same?

    @NeilGirdhar NeilGirdhar mannequin added the stdlib Python modules in the Lib dir label Aug 19, 2016
    @vadmium
    Copy link
    Member

    vadmium commented Aug 19, 2016

    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.

    @vadmium vadmium added the type-feature A feature request or enhancement label Aug 19, 2016
    @NeilGirdhar
    Copy link
    Mannequin Author

    NeilGirdhar mannequin commented Aug 19, 2016

    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.

    @NeilGirdhar
    Copy link
    Mannequin Author

    NeilGirdhar mannequin commented Aug 19, 2016

    (there's already an open thread.)

    @bitdancer
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants