Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6aa3c1a0
Commit
6aa3c1a0
authored
May 12, 2015
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce the overhead in functools.total_ordering by localizing NotImplemented.
(Sugguested by Serhiy Storchaka)
parent
c4766cf1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
Lib/functools.py
Lib/functools.py
+12
-12
No files found.
Lib/functools.py
View file @
6aa3c1a0
...
...
@@ -94,80 +94,80 @@ def wraps(wrapped,
# infinite recursion that could occur when the operator dispatch logic
# detects a NotImplemented result and then calls a reflected method.
def
_gt_from_lt
(
self
,
other
):
def
_gt_from_lt
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'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
op_result
return
not
op_result
and
self
!=
other
def
_le_from_lt
(
self
,
other
):
def
_le_from_lt
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'Return a <= b. Computed by @total_ordering from (a < b) or (a == b).'
op_result
=
self
.
__lt__
(
other
)
return
op_result
or
self
==
other
def
_ge_from_lt
(
self
,
other
):
def
_ge_from_lt
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'Return a >= b. Computed by @total_ordering from (not a < b).'
op_result
=
self
.
__lt__
(
other
)
if
op_result
is
NotImplemented
:
return
op_result
return
not
op_result
def
_ge_from_le
(
self
,
other
):
def
_ge_from_le
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'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
op_result
return
not
op_result
or
self
==
other
def
_lt_from_le
(
self
,
other
):
def
_lt_from_le
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'Return a < b. Computed by @total_ordering from (a <= b) and (a != b).'
op_result
=
self
.
__le__
(
other
)
if
op_result
is
NotImplemented
:
return
op_result
return
op_result
and
self
!=
other
def
_gt_from_le
(
self
,
other
):
def
_gt_from_le
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'Return a > b. Computed by @total_ordering from (not a <= b).'
op_result
=
self
.
__le__
(
other
)
if
op_result
is
NotImplemented
:
return
op_result
return
not
op_result
def
_lt_from_gt
(
self
,
other
):
def
_lt_from_gt
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'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
op_result
return
not
op_result
and
self
!=
other
def
_ge_from_gt
(
self
,
other
):
def
_ge_from_gt
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'Return a >= b. Computed by @total_ordering from (a > b) or (a == b).'
op_result
=
self
.
__gt__
(
other
)
return
op_result
or
self
==
other
def
_le_from_gt
(
self
,
other
):
def
_le_from_gt
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'Return a <= b. Computed by @total_ordering from (not a > b).'
op_result
=
self
.
__gt__
(
other
)
if
op_result
is
NotImplemented
:
return
op_result
return
not
op_result
def
_le_from_ge
(
self
,
other
):
def
_le_from_ge
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'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
op_result
return
not
op_result
or
self
==
other
def
_gt_from_ge
(
self
,
other
):
def
_gt_from_ge
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'Return a > b. Computed by @total_ordering from (a >= b) and (a != b).'
op_result
=
self
.
__ge__
(
other
)
if
op_result
is
NotImplemented
:
return
op_result
return
op_result
and
self
!=
other
def
_lt_from_ge
(
self
,
other
):
def
_lt_from_ge
(
self
,
other
,
NotImplemented
=
NotImplemented
):
'Return a < b. Computed by @total_ordering from (not a >= b).'
op_result
=
self
.
__ge__
(
other
)
if
op_result
is
NotImplemented
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment