Skip to content

Reorder PyNumberBinaryOp to match NB_* constants#7512

Merged
youknowone merged 1 commit intoRustPython:mainfrom
youknowone:nb-slots
Mar 27, 2026
Merged

Reorder PyNumberBinaryOp to match NB_* constants#7512
youknowone merged 1 commit intoRustPython:mainfrom
youknowone:nb-slots

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Mar 27, 2026

Align variant ordering with BinaryOperator enum and CPython's NB_* constants from opcode.h. Divmod is placed last as it has no corresponding NB_* constant.

Summary by CodeRabbit

  • Chores
    • Internal code reorganization to align with Python conventions. No user-facing changes.

Align variant ordering with BinaryOperator enum and
CPython's NB_* constants from opcode.h. Divmod is placed
last as it has no corresponding NB_* constant.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 27, 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: 9f24d04b-66eb-42b1-8b0c-fac239474a3c

📥 Commits

Reviewing files that changed from the base of the PR and between 9282a87 and 5c80cee.

📒 Files selected for processing (1)
  • crates/vm/src/protocol/number.rs

📝 Walkthrough

Walkthrough

Reorders variants in the PyNumberBinaryOp enum to align with the NB_* constants ordering from opcode.h. This is a structural reorganization of enum variant sequence without functional changes to existing methods.

Changes

Cohort / File(s) Summary
Enum Variant Reordering
crates/vm/src/protocol/number.rs
Reordered PyNumberBinaryOp enum variants including Add, Subtract, Multiply, Remainder, And, FloorDivide, Lshift, MatrixMultiply, Or, Rshift, TrueDivide, Xor, Divmod and their corresponding Inplace* variants to match NB_* constants ordering from opcode.h. No functional changes to methods.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • Unify BINARY_OP bytecodes #6317: Directly related enum variant reordering to align operator discriminants with unified NB_* and bytecode-level BinaryOp ordering.

Poem

🐰 Hop, hop! The operators dance in line,
Now sorted like opcode.h does design,
No logic bent, just variants rearranged,
Order brings harmony, all has changed! 📋✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: reordering the PyNumberBinaryOp enum to match NB_* constants from opcode.h, which is the primary objective of the pull request.

✏️ 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.

@youknowone youknowone marked this pull request as ready for review March 27, 2026 01:54
@youknowone youknowone merged commit a91127c into RustPython:main Mar 27, 2026
15 checks passed
@youknowone youknowone deleted the nb-slots branch March 27, 2026 03:41
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