← Winnitude! Search  ·  Reader Mode (1510 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 37 LINKS

Newtype `LoadSuperAttr` oparg by ShaharNaveh · Pull Request #7002 · RustPython/RustPython

Repository navigation

Newtype LoadSuperAttr oparg - #7002


Merged
youknowone merged 1 commit into RustPython:main from ShaharNaveh:oparg-newtype-loadsuperattr Feb 5, 2026
Merged

Newtype LoadSuperAttr oparg #7002 youknowone merged 1 commit into RustPython:main from ShaharNaveh:oparg-newtype-loadsuperattr

Conversation

ShaharNaveh commented Feb 5, 2026 · edited by coderabbitai
Bot
Loading



Copy link Copy Markdown
Contributor

If this will be merged I'll do the same for LoadAttr opcode

Summary by CodeRabbit

  • Refactor
    • Refactored super attribute loading mechanism to use a structured builder-based approach instead of low-level encoding calls.
    • Enhanced bytecode argument handling with improved type safety for super attribute operations.
    • Reorganized public API exports to support the new structured argument type handling.
Newtype LoadSuperAttr oparg 778776d

coderabbitai
Bot
commented Feb 5, 2026 · edited Loading



Copy link Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes refactor super-attribute loading instruction handling by replacing low-level u32 encoding/decoding with a typed LoadSuperAttr struct using a builder pattern. This spans compiler codegen, bytecode definitions, and VM execution, removing old encode/decode helper functions and introducing a strongly-typed oparg representation.

Changes

Cohort / File(s) Summary
Oparg Type Definition
crates/compiler-core/src/bytecode/oparg.rs
Introduces new public LoadSuperAttr struct with three bit-field accessors (name_idx, is_load_method, has_class), a builder pattern via LoadSuperAttrBuilder, and trait implementations for OpArgType conversion and u32 interop.
Instruction Type Updates
crates/compiler-core/src/bytecode/instruction.rs
Changes LoadSuperAttr variant argument type from Arg to Arg, removes encode_load_super_attr_arg and decode_load_super_attr_arg functions, and updates display/serialization to use typed accessors.
Bytecode Exports
crates/compiler-core/src/bytecode.rs
Removes instruction re-exports for encode/decode_load_super_attr_arg and encode/decode_load_attr_arg; adds LoadSuperAttr to oparg public exports.
Codegen Integration
crates/codegen/src/compile.rs
Replaces four emit helpers (emit_load_super_attr, emit_load_super_method, emit_load_zero_super_attr, emit_load_zero_super_method) to construct LoadSuperAttr via builder instead of calling encode_load_super_attr_arg; imports LoadSuperAttr in public module.
VM Execution
crates/vm/src/frame.rs
Updates load_super_attr method signature to accept oparg: LoadSuperAttr instead of oparg: u32; refactors argument extraction to use LoadSuperAttr accessor methods (name_idx(), is_load_method(), has_class()).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • youknowone

Poem

🐰 A builder so clean, no encode in sight,
LoadSuperAttr shines with typed delight!
From u32's murk to fields so bright,
Super attributes now structured just right. ✨

🚥 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 'Newtype LoadSuperAttr oparg' accurately summarizes the main change: introducing a newtype wrapper for the LoadSuperAttr opcode argument, which is reflected across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 95.65% 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 docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 approved these changes Feb 5, 2026
View reviewed changes

youknowone left a comment



Copy link Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more .

👍

youknowone merged commit 5b7db1d into RustPython : main Feb 5, 2026 youknowone pushed a commit that referenced this pull request Sep 16, 2026 Newtype LoadSuperAttr oparg (#7002) 57496bb Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

2 participants