Remove oparg builders by ShaharNaveh · Pull Request #7537 · RustPython/RustPython
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 0d6d7117-cced-4dab-9361-3cb8fd8f38d6
📒 Files selected for processing (2)
crates/codegen/src/compile.rscrates/compiler-core/src/bytecode/oparg.rs
📝 Walkthrough
Walkthrough
Replaced the builder-pattern API for LoadAttr and LoadSuperAttr bytecode argument types with direct const fn new(...) constructors. The changes remove builder structs and methods from the type definitions and update all call sites in the bytecode emission code to use the new constructors instead.
Changes
| Cohort / File(s) | Summary |
|---|---|
Bytecode Oparg Type Definitions crates/compiler-core/src/bytecode/oparg.rs |
Removed LoadAttrBuilder and LoadSuperAttrBuilder structs along with their builder methods. Added LoadAttr::new(name_idx, is_method) and LoadSuperAttr::new(name_idx, is_load_method, has_class) as const fn constructors that perform field packing inline. |
Bytecode Emission Call Sites crates/codegen/src/compile.rs |
Updated six private helper methods (emit_load_attr, emit_load_attr_method, emit_load_super_attr, emit_load_super_method, emit_load_zero_super_attr, emit_load_zero_super_method) to call the new constructors directly instead of using builder methods. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- Newtype
var_numsoparg #7431: Modifies the sameLoadAttrandLoadSuperAttroparg types and their bit-packing logic inoparg.rs. - Newtype
LoadAttroparg #7047: Updates the same oparg types and their usage patterns incompile.rsfor attribute loading instructions. - Newtype oparg align methods #7403: Refactors the same
LoadAttrandLoadSuperAttrtypes inoparg.rswith alternative constructor and representation approaches.
Suggested reviewers
- youknowone
Poem
🐰 Builders once nested, now constructors shine,
const fn packing, fields align,
No more patterns, just direct and clean,
The fastest bytecode ever seen! ✨
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Remove oparg builders' directly and accurately reflects the main change: replacing builder-pattern APIs with direct constructors in the oparg module, affecting LoadAttr and LoadSuperAttr types. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.