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

Overwriting __contains__ #5

Open
nikohansen opened this issue Sep 29, 2021 · 0 comments
Open

Overwriting __contains__ #5

nikohansen opened this issue Sep 29, 2021 · 0 comments

Comments

@nikohansen
Copy link
Contributor

nikohansen commented Sep 29, 2021

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant