Skip to content

Commit

Permalink
optimize _find_first_app_frame_and_name (#607)
Browse files Browse the repository at this point in the history
* optimize stdlib findCaller

* use for-else instead of any(...)

* use str.startswith(tuple)

---------

Co-authored-by: Hynek Schlawack <[email protected]>
  • Loading branch information
methane and hynek authored Apr 2, 2024
1 parent 9c44b24 commit c34da02
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/structlog/_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def _find_first_app_frame_and_name(
Returns:
tuple of (frame, name)
"""
ignores = ["structlog"] + (additional_ignores or [])
ignores = tuple(["structlog"] + (additional_ignores or []))
f = _ASYNC_CALLING_STACK.get(_getframe())
name = f.f_globals.get("__name__") or "?"
while any(tuple(name.startswith(i) for i in ignores)):
while name.startswith(ignores):
if f.f_back is None:
name = "?"
break
Expand Down

0 comments on commit c34da02

Please sign in to comment.