Skip to content

Commit e3cf5fa

Browse files
committed
inspect: fast path _shadowed_dict for type
1 parent 0bf6e31 commit e3cf5fa

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Lib/inspect.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,9 @@ def _shadowed_dict(klass):
17401740
# destroyed, and the dynamically created classes happen to be the only
17411741
# objects that hold strong references to other objects that take up a
17421742
# significant amount of memory.
1743+
# Fast path: `type` is the dominant caller; result is always _sentinel.
1744+
if klass is type:
1745+
return _sentinel
17431746
return _shadowed_dict_from_weakref_mro_tuple(
17441747
*[make_weakref(entry) for entry in _static_getmro(klass)]
17451748
)

0 commit comments

Comments
 (0)