Skip to content

Commit dba7cb9

Browse files
authored
gh-142418: Remove unnecessary cycle detection from _has_coroutine_mark
Partial and method objects cannot form reference cycles in this context, so the cycle-detection logic in _has_coroutine_mark introduced unnecessary overhead. This change removes the visited-set check and keeps the function as a simple unwrapping loop while still correctly detecting explicitly marked coroutine wrappers.
1 parent 6117107 commit dba7cb9

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

Lib/inspect.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,7 @@ def isgeneratorfunction(obj):
306306
_is_coroutine_mark = object()
307307

308308
def _has_coroutine_mark(f):
309-
visited = set()
310309
while True:
311-
if id(f) in visited:
312-
return False
313-
visited.add(id(f))
314-
315310
if getattr(f, "_is_coroutine_marker", None) is _is_coroutine_mark:
316311
return True
317312

0 commit comments

Comments
 (0)