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
692b3400
Commit
692b3400
authored
May 14, 2015
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inspect: Micro-optimize __eq__ for Signature, Parameter and BoundArguments
Provide __ne__ method for consistency.
parent
8aad7f27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
Lib/inspect.py
Lib/inspect.py
+22
-10
No files found.
Lib/inspect.py
View file @
692b3400
...
@@ -2353,11 +2353,15 @@ class Parameter:
...
@@ -2353,11 +2353,15 @@ class Parameter:
return
hash
((
self
.
name
,
self
.
kind
,
self
.
annotation
,
self
.
default
))
return
hash
((
self
.
name
,
self
.
kind
,
self
.
annotation
,
self
.
default
))
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
return
(
issubclass
(
other
.
__class__
,
Parameter
)
and
return
(
self
is
other
or
self
.
_name
==
other
.
_name
and
(
issubclass
(
other
.
__class__
,
Parameter
)
and
self
.
_kind
==
other
.
_kind
and
self
.
_name
==
other
.
_name
and
self
.
_default
==
other
.
_default
and
self
.
_kind
==
other
.
_kind
and
self
.
_annotation
==
other
.
_annotation
)
self
.
_default
==
other
.
_default
and
self
.
_annotation
==
other
.
_annotation
))
def
__ne__
(
self
,
other
):
return
not
self
.
__eq__
(
other
)
class
BoundArguments
:
class
BoundArguments
:
...
@@ -2441,9 +2445,13 @@ class BoundArguments:
...
@@ -2441,9 +2445,13 @@ class BoundArguments:
return
kwargs
return
kwargs
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
return
(
issubclass
(
other
.
__class__
,
BoundArguments
)
and
return
(
self
is
other
or
self
.
signature
==
other
.
signature
and
(
issubclass
(
other
.
__class__
,
BoundArguments
)
and
self
.
arguments
==
other
.
arguments
)
self
.
signature
==
other
.
signature
and
self
.
arguments
==
other
.
arguments
))
def
__ne__
(
self
,
other
):
return
not
self
.
__eq__
(
other
)
def
__setstate__
(
self
,
state
):
def
__setstate__
(
self
,
state
):
self
.
_signature
=
state
[
'_signature'
]
self
.
_signature
=
state
[
'_signature'
]
...
@@ -2663,8 +2671,12 @@ class Signature:
...
@@ -2663,8 +2671,12 @@ class Signature:
return
hash
((
params
,
kwo_params
,
return_annotation
))
return
hash
((
params
,
kwo_params
,
return_annotation
))
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
return
(
isinstance
(
other
,
Signature
)
and
return
(
self
is
other
or
self
.
_hash_basis
()
==
other
.
_hash_basis
())
(
isinstance
(
other
,
Signature
)
and
self
.
_hash_basis
()
==
other
.
_hash_basis
()))
def
__ne__
(
self
,
other
):
return
not
self
.
__eq__
(
other
)
def
_bind
(
self
,
args
,
kwargs
,
*
,
partial
=
False
):
def
_bind
(
self
,
args
,
kwargs
,
*
,
partial
=
False
):
"""Private method. Don't use directly."""
"""Private method. Don't use directly."""
...
...
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