Repository navigation
Update Trivial Inference for Python 3.15 - #40578
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR updates the bytecode-based trivial type inference state machine (opcodes.py and trivial_inference.py) to accommodate Python 3.15 bytecode changes. It properly handles the new two-slot iterator stack representation (GET_ITER, FOR_ITER, POP_ITER, END_SEND), the expanded LOAD_COMMON_CONSTANT opcode, and generator expression call patterns where GET_ITER moved inside the generator code object.
🔍 General Feedback
- The changes are well-isolated with
sys.version_infochecks, ensuring full backwards compatibility with existing Python versions. - Stack-relative adjustments and constant table lookups are handled cleanly with clear inline documentation explaining the CPython 3.15 runtime mechanics.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @damccorm for label python. This pull request likely touches a core component ("core" label). Please review with scrutiny. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40578 +/- ##
=============================================
+ Coverage 56.16% 79.92% +23.75%
=============================================
Files 1124 488 -636
Lines 178336 82362 -95974
Branches 1489 0 -1489
=============================================
- Hits 100170 65831 -34339
+ Misses 75645 16531 -59114
+ Partials 2521 0 -2521
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
damccorm
left a comment
There was a problem hiding this comment.
Generally LGTM, but had one question
| state.stack.append(Const(arg)) | ||
|
|
||
|
|
||
| def load_common_constant(state, arg): |
There was a problem hiding this comment.
It doesn't have a direct call but will be used when the typehint tests run on 3.15. The functions defined in opcodes.py get imported in infer_return_type_func() and placed into a dictionary, then invoked through that dict entry rather than calling the function directly. This is the general convention for any operation that doesn't do more complex behavior like modifying the program counter
Updates the trivial inference state machine for Python 3.15 opcodes. Tested locally; will not be exercised on-repo until 3.15 support is added outright.
Part of #40249