Skip to content

Overwriting __contains__ #5

@nikohansen

Description

@nikohansen

The BiobjectiveNondominatedSortedList class should overwrite __contains___ when the list is (very) long with something like

idx = self.bisect_left(f_pair)
return idx < len(self) and self[idx] == f_pair

https://docs.python.org/3/reference/datamodel.html#object.__contains__

We may also consider to inherit from sortedcontainers.SortedList instead of list (though we cannot useupdate to implement add_list).

We should first check whether and when we actually get a relevance performance gain, as Python's in seems to be very fast (80ns with 1 million entries).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions