File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -1772,9 +1772,9 @@ def trace(context=1):
17721772# ------------------------------------------------ static version of getattr
17731773
17741774_sentinel = object ()
1775+ _static_getmro = type .__dict__ ['__mro__' ].__get__
1776+ _get_dunder_dict_of_class = type .__dict__ ["__dict__" ].__get__
17751777
1776- def _static_getmro (klass ):
1777- return type .__dict__ ['__mro__' ].__get__ (klass )
17781778
17791779def _check_instance (obj , attr ):
17801780 instance_dict = {}
@@ -1802,10 +1802,9 @@ def _is_type(obj):
18021802 return True
18031803
18041804def _shadowed_dict (klass ):
1805- dict_attr = type .__dict__ ["__dict__" ]
18061805 for entry in _static_getmro (klass ):
18071806 try :
1808- class_dict = dict_attr . __get__ (entry )["__dict__" ]
1807+ class_dict = _get_dunder_dict_of_class (entry )["__dict__" ]
18091808 except KeyError :
18101809 pass
18111810 else :
Original file line number Diff line number Diff line change 1+ Improve performance of :func: `inspect.getattr_static `. Patch by Alex
2+ Waygood.
You can’t perform that action at this time.
0 commit comments