]> granicus.if.org Git - python/commitdiff
Conceptually, roots is a set. Also searching it as a set is a tiny bit faster (...
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Tue, 5 Sep 2017 16:40:44 +0000 (09:40 -0700)
committerGitHub <noreply@github.com>
Tue, 5 Sep 2017 16:40:44 +0000 (09:40 -0700)
Lib/functools.py

index 0873f207154b7daab8a39c8fadc9923977e509f2..23ad16093007e99b6b63aa3c2f9a270067d54aee 100644 (file)
@@ -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__