Bytecode oparg optimization#7032
Conversation
📝 WalkthroughWalkthroughThis PR refactors bytecode enum handling and casting patterns across the compiler. It replaces explicit u32 casts with standard conversion functions (u32::from()), removes the num_enum dependency, adds Debug derives to bytecode types, macro-generates oparg enum definitions and trait implementations, and removes const qualifiers from eval_ord methods. All changes maintain functional equivalence while modernizing the codebase. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
| $vis enum $name { | ||
| $( | ||
| $(#[$variant_meta])* | ||
| $variant, // Do assign value to variant. |
There was a problem hiding this comment.
@youknowone This breaks RustPython. if I put $variant = $value then everything works just fine.
I suspect that there's some unsafe transmuting somewhere, do you have an idea how can I debug this?
There was a problem hiding this comment.
After lots of debugging I've figured that the only problematic enum is ComparisonOperator. I'm not sure about why yet, but it's not related to an unsafe transmutation like I initially thought
There was a problem hiding this comment.
ComparisonOperator seems to support bit operation. It doesn't have 0 like other enums
Discussed at #6980 (comment)
Pretty much reverts #6980.
Summary by CodeRabbit
Chores
Refactor