File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -87,18 +87,19 @@ def _(cand: None) -> types.ModuleType:
8787 return resolve (_infer_caller ().f_globals ['__name__' ])
8888
8989
90+ @functools .lru_cache
91+ def _this_filename ():
92+ frame = inspect .currentframe ()
93+ return __file__ if frame is None else inspect .getframeinfo (frame ).filename
94+
95+
9096def _infer_caller ():
9197 """
9298 Walk the stack and find the frame of the first caller not in this module.
9399 """
94- this_frame = inspect .currentframe ()
95- if this_frame is None :
96- this_file = __file__
97- else :
98- this_file = inspect .getframeinfo (this_frame ).filename
99100
100101 def is_this_file (frame_info ):
101- return frame_info .filename == this_file
102+ return frame_info .filename == _this_filename ()
102103
103104 def is_wrapper (frame_info ):
104105 return frame_info .function == 'wrapper'
You can’t perform that action at this time.
0 commit comments