Skip to content

OrderedSet.pop() with a non-default index breaks the contract #83

@rspeer

Description

@rspeer
>>> from ordered_set import OrderedSet
>>> a = OrderedSet(["a", "b", "c"])
>>> a.index("b")
1
>>> a.pop(0)
'a'
>>> a.index("b")
1
>>> a[1]
'c'

This was revealed by looking into #79. pop() would need to rebuild the mapping in place, like discard() does. Its current behavior, which only works for index=-1, would be an optimization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions