summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-04-05 07:27:01 (GMT)
committerGitHub <noreply@github.com>2023-04-05 07:27:01 (GMT)
commit264c00a1c512a9bd58f47c80e72e436c639763c8 (patch)
tree51db9d971301ac0eae93720029f057d44402ecbb /Lib/inspect.py
parent119f67de08f1fddc2a3f7b7caac7454cb57ef800 (diff)
downloadcpython-264c00a1c512a9bd58f47c80e72e436c639763c8.zip
cpython-264c00a1c512a9bd58f47c80e72e436c639763c8.tar.gz
cpython-264c00a1c512a9bd58f47c80e72e436c639763c8.tar.bz2
gh-103193: Micro-optimise helper functions for `inspect.getattr_static` (#103195)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 0eceaaf..8739c9c 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1772,9 +1772,9 @@ def trace(context=1):
# ------------------------------------------------ static version of getattr
_sentinel = object()
+_static_getmro = type.__dict__['__mro__'].__get__
+_get_dunder_dict_of_class = type.__dict__["__dict__"].__get__
-def _static_getmro(klass):
- return type.__dict__['__mro__'].__get__(klass)
def _check_instance(obj, attr):
instance_dict = {}
@@ -1802,10 +1802,9 @@ def _is_type(obj):
return True
def _shadowed_dict(klass):
- dict_attr = type.__dict__["__dict__"]
for entry in _static_getmro(klass):
try:
- class_dict = dict_attr.__get__(entry)["__dict__"]
+ class_dict = _get_dunder_dict_of_class(entry)["__dict__"]
except KeyError:
pass
else: