Repository navigation
Keep coroutine generator expressions on the ordinary call path - #9075
Conversation
Match Python 3.14 by excluding coroutine-marked generator expressions from builtin call optimization. Reuse the existing cursor-preserving comprehension lookup so nested outer iterable scopes do not select the wrong symbol table; propagate lookup errors. Assisted-by: OpenAI Codex:model identifier unavailable
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No actionable issue is identified; the change is mergeable after normal checks. Pre-merge checks |
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03a750bbf0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| has_common_constant(f, bytecode::CommonConstant::BuiltinAny), | ||
| "maybe_optimize_function_call() guards any(genexpr) whether or not the \ | ||
| generator is a coroutine: {source}" | ||
| !has_common_constant(f, bytecode::CommonConstant::BuiltinAny), |
There was a problem hiding this comment.
Do not flip the existing unit-test assertions
This block reverses the existing structural expectations and the same test adds new source fixtures, but the repository’s test-code policy explicitly prohibits modifying assertions, logic, or test data; this behavior change needs a policy-compliant test strategy or an explicit exception before landing.
AGENTS.md reference: AGENTS.md:L273-L279
Useful? React with 👍 / 👎.
Summary
Extract the Python 3.14 coroutine-generator guard from #8954: coroutine-marked generator expressions must use the ordinary call path rather than the guarded all/any/tuple loop optimization.
The literal mega guard reads the next symbol subtable, which can belong to a nested expression in the outer iterable. This patch instead reuses the existing cursor-preserving comprehension-table lookup and propagates lookup errors. The lookup is computed once; no runtime, opcode, symbol-table construction, or generator lifecycle changes are introduced.
This matches the guard already present in CPython 3.14.7 and 3.14.8. The Python 3.15 list/set optimization additions remain separate.
Validation
This is compiler-shape compatibility, not a claimed crash repair or measured performance improvement. The full hosted matrix remains required.
Summary by CodeRabbit
tuple,all, andanycalls handle generator expressions involving coroutines. These expressions now follow the ordinary call path when appropriate, while eligible non-coroutine expressions retain the optimized path. This improves correctness for asynchronous iteration and nestedawaitexpressions.