summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 95da7fb..a64e85e 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1794,8 +1794,9 @@ def _check_class(klass, attr):
return entry.__dict__[attr]
return _sentinel
-def _shadowed_dict(klass):
- for entry in _static_getmro(klass):
+@functools.lru_cache()
+def _shadowed_dict_from_mro_tuple(mro):
+ for entry in mro:
dunder_dict = _get_dunder_dict_of_class(entry)
if '__dict__' in dunder_dict:
class_dict = dunder_dict['__dict__']
@@ -1805,6 +1806,9 @@ def _shadowed_dict(klass):
return class_dict
return _sentinel
+def _shadowed_dict(klass):
+ return _shadowed_dict_from_mro_tuple(_static_getmro(klass))
+
def getattr_static(obj, attr, default=_sentinel):
"""Retrieve attributes without triggering dynamic lookup via the
descriptor protocol, __getattr__ or __getattribute__.