diff options
author | Raymond Hettinger <python@rcn.com> | 2015-01-07 06:16:10 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-01-07 06:16:10 (GMT) |
commit | e5db863c224f32103760d1c745acf9b140a40902 (patch) | |
tree | 12542131f9c9b79a17b17a3e5443e45b9a5e7258 /Lib/functools.py | |
parent | f212636fe3fd6505e0de2dafbe7d0a7ab27031cd (diff) | |
download | cpython-e5db863c224f32103760d1c745acf9b140a40902.zip cpython-e5db863c224f32103760d1c745acf9b140a40902.tar.gz cpython-e5db863c224f32103760d1c745acf9b140a40902.tar.bz2 |
Minor speed-up. Use local variable instead of a global lookup.
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 6f79472..2ae8313 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -98,7 +98,7 @@ def _gt_from_lt(self, other): 'Return a > b. Computed by @total_ordering from (not a < b) and (a != b).' op_result = self.__lt__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return not op_result and self != other def _le_from_lt(self, other): @@ -110,35 +110,35 @@ def _ge_from_lt(self, other): 'Return a >= b. Computed by @total_ordering from (not a < b).' op_result = self.__lt__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return not op_result def _ge_from_le(self, other): 'Return a >= b. Computed by @total_ordering from (not a <= b) or (a == b).' op_result = self.__le__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return not op_result or self == other def _lt_from_le(self, other): 'Return a < b. Computed by @total_ordering from (a <= b) and (a != b).' op_result = self.__le__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return op_result and self != other def _gt_from_le(self, other): 'Return a > b. Computed by @total_ordering from (not a <= b).' op_result = self.__le__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return not op_result def _lt_from_gt(self, other): 'Return a < b. Computed by @total_ordering from (not a > b) and (a != b).' op_result = self.__gt__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return not op_result and self != other def _ge_from_gt(self, other): @@ -150,28 +150,28 @@ def _le_from_gt(self, other): 'Return a <= b. Computed by @total_ordering from (not a > b).' op_result = self.__gt__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return not op_result def _le_from_ge(self, other): 'Return a <= b. Computed by @total_ordering from (not a >= b) or (a == b).' op_result = self.__ge__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return not op_result or self == other def _gt_from_ge(self, other): 'Return a > b. Computed by @total_ordering from (a >= b) and (a != b).' op_result = self.__ge__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return op_result and self != other def _lt_from_ge(self, other): 'Return a < b. Computed by @total_ordering from (not a >= b).' op_result = self.__ge__(other) if op_result is NotImplemented: - return NotImplemented + return op_result return not op_result def total_ordering(cls): |