Skip to content

Constify OpArgState methods#7616

Open
ShaharNaveh wants to merge 1 commit intoRustPython:mainfrom
ShaharNaveh:constify-oparg-state-methods
Open

Constify OpArgState methods#7616
ShaharNaveh wants to merge 1 commit intoRustPython:mainfrom
ShaharNaveh:constify-oparg-state-methods

Conversation

@ShaharNaveh
Copy link
Copy Markdown
Contributor

@ShaharNaveh ShaharNaveh commented Apr 16, 2026

Summary by CodeRabbit

  • Refactor
    • Enhanced bytecode argument handling infrastructure with new conversion methods and compile-time evaluation capabilities.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 16, 2026

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: 86e91b84-498a-4a09-8725-f6e42844ae5f

📥 Commits

Reviewing files that changed from the base of the PR and between aa12acc and 9078ddf.

📒 Files selected for processing (1)
  • crates/compiler-core/src/bytecode/oparg.rs

📝 Walkthrough

Walkthrough

This change adds const accessor methods to OpArgByte and makes OpArgState::get and OpArgState::extend const functions to enable compile-time evaluation of opcode-argument decoding operations. Implementation details are updated to use the new const methods instead of direct field access.

Changes

Cohort / File(s) Summary
Bytecode OpArg Constants
crates/compiler-core/src/bytecode/oparg.rs
Added as_u8() and as_u32() const accessor methods to OpArgByte. Changed OpArgState::get and OpArgState::extend to const fn and refactored implementations to use the new accessors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Const functions dance in morning light,
Compile-time magic, pure delight!
OpArgs now race at zero-cost,
No runtime overhead is lost.

🚥 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 'Constify OpArgState methods' directly and clearly summarizes the main change—converting OpArgState methods to const functions for compile-time evaluation.
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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant