mirror of
https://github.com/python/cpython
synced 2024-09-16 03:49:58 +00:00
Conceptually, roots is a set. Also searching it as a set is a tiny bit faster (#3338)
This commit is contained in:
parent
75b961869a
commit
15ce0bee97
|
@ -193,7 +193,7 @@ def _lt_from_ge(self, other, NotImplemented=NotImplemented):
|
||||||
def total_ordering(cls):
|
def total_ordering(cls):
|
||||||
"""Class decorator that fills in missing ordering methods"""
|
"""Class decorator that fills in missing ordering methods"""
|
||||||
# Find user-defined comparisons (not those inherited from object).
|
# Find user-defined comparisons (not those inherited from object).
|
||||||
roots = [op for op in _convert if getattr(cls, op, None) is not getattr(object, op, None)]
|
roots = {op for op in _convert if getattr(cls, op, None) is not getattr(object, op, None)}
|
||||||
if not roots:
|
if not roots:
|
||||||
raise ValueError('must define at least one ordering operation: < > <= >=')
|
raise ValueError('must define at least one ordering operation: < > <= >=')
|
||||||
root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
|
root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
|
||||||
|
|
Loading…
Reference in a new issue