Kaydet (Commit) 15ce0bee authored tarafından Raymond Hettinger's avatar Raymond Hettinger Kaydeden (comit) GitHub

Conceptually, roots is a set. Also searching it as a set is a tiny bit faster (#3338)

üst 75b96186
......@@ -193,7 +193,7 @@ _convert = {
def total_ordering(cls):
"""Class decorator that fills in missing ordering methods"""
# 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:
raise ValueError('must define at least one ordering operation: < > <= >=')
root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment