Skip to content

Commit e5db863

Browse files
committed
Minor speed-up. Use local variable instead of a global lookup.
1 parent f212636 commit e5db863

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Lib/functools.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def _gt_from_lt(self, other):
9898
'Return a > b. Computed by @total_ordering from (not a < b) and (a != b).'
9999
op_result = self.__lt__(other)
100100
if op_result is NotImplemented:
101-
return NotImplemented
101+
return op_result
102102
return not op_result and self != other
103103

104104
def _le_from_lt(self, other):
@@ -110,35 +110,35 @@ def _ge_from_lt(self, other):
110110
'Return a >= b. Computed by @total_ordering from (not a < b).'
111111
op_result = self.__lt__(other)
112112
if op_result is NotImplemented:
113-
return NotImplemented
113+
return op_result
114114
return not op_result
115115

116116
def _ge_from_le(self, other):
117117
'Return a >= b. Computed by @total_ordering from (not a <= b) or (a == b).'
118118
op_result = self.__le__(other)
119119
if op_result is NotImplemented:
120-
return NotImplemented
120+
return op_result
121121
return not op_result or self == other
122122

123123
def _lt_from_le(self, other):
124124
'Return a < b. Computed by @total_ordering from (a <= b) and (a != b).'
125125
op_result = self.__le__(other)
126126
if op_result is NotImplemented:
127-
return NotImplemented
127+
return op_result
128128
return op_result and self != other
129129

130130
def _gt_from_le(self, other):
131131
'Return a > b. Computed by @total_ordering from (not a <= b).'
132132
op_result = self.__le__(other)
133133
if op_result is NotImplemented:
134-
return NotImplemented
134+
return op_result
135135
return not op_result
136136

137137
def _lt_from_gt(self, other):
138138
'Return a < b. Computed by @total_ordering from (not a > b) and (a != b).'
139139
op_result = self.__gt__(other)
140140
if op_result is NotImplemented:
141-
return NotImplemented
141+
return op_result
142142
return not op_result and self != other
143143

144144
def _ge_from_gt(self, other):
@@ -150,28 +150,28 @@ def _le_from_gt(self, other):
150150
'Return a <= b. Computed by @total_ordering from (not a > b).'
151151
op_result = self.__gt__(other)
152152
if op_result is NotImplemented:
153-
return NotImplemented
153+
return op_result
154154
return not op_result
155155

156156
def _le_from_ge(self, other):
157157
'Return a <= b. Computed by @total_ordering from (not a >= b) or (a == b).'
158158
op_result = self.__ge__(other)
159159
if op_result is NotImplemented:
160-
return NotImplemented
160+
return op_result
161161
return not op_result or self == other
162162

163163
def _gt_from_ge(self, other):
164164
'Return a > b. Computed by @total_ordering from (a >= b) and (a != b).'
165165
op_result = self.__ge__(other)
166166
if op_result is NotImplemented:
167-
return NotImplemented
167+
return op_result
168168
return op_result and self != other
169169

170170
def _lt_from_ge(self, other):
171171
'Return a < b. Computed by @total_ordering from (not a >= b).'
172172
op_result = self.__ge__(other)
173173
if op_result is NotImplemented:
174-
return NotImplemented
174+
return op_result
175175
return not op_result
176176

177177
def total_ordering(cls):

0 commit comments

Comments
 (0)