◐ Shell
reader mode source ↗
Skip to content

Update opcode from 3.13.7#6156

Merged
youknowone merged 16 commits into
RustPython:mainfrom
ShaharNaveh:update-opcode
Oct 5, 2025
Merged

Update opcode from 3.13.7#6156
youknowone merged 16 commits into
RustPython:mainfrom
ShaharNaveh:update-opcode

Conversation

@ShaharNaveh

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests
  • 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.

@ShaharNaveh ShaharNaveh changed the title Impl _opcode. Update dis from 3.13.7 Sep 18, 2025
@ShaharNaveh ShaharNaveh marked this pull request as ready for review September 18, 2025 14:53
@youknowone

Copy link
Copy Markdown
Member

finally we get _opcode, great!

@ShaharNaveh

ShaharNaveh commented Sep 25, 2025

Copy link
Copy Markdown
Contributor Author

For some reason I can't comment on the thread of #6156 (comment) so answering it here:

Does giving specific numbers to each instruction make it easier to be maintained? I guess so.

Yes! it also makes it easier for writing the helpers of:

  • is_valid
  • has_arg
  • has_const
  • has_name
  • etc...

but that wouldn't be needed as I intend #6174 to generate those automatically (just like CPython does it)

After #6174, then can we rewrite 63 | 66 to Instruction::Abc as u8 | Instruction::Def as u8 and so on?

Well, yes you could. but I thought that we could have an API that looks similar to this:

// This is inside the `_opcode` module
fn has_arg(opcode: i32) -> bool {
  Instruction::try_from(opcode).map_or(false, |v| !v.is_pseudo() && v.has_arg())
}

where:

  • Instruction::try_from
  • instruction.is_pseudo()
  • instruction.has_arg()

are all auto generated.

@youknowone 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.

Hide comment

Looks good in general.

I am worrying about the newly introduced magic numbers. I wish it could be quickly resolved in next patch

Hide details View details @youknowone youknowone merged commit 3a6fda4 into RustPython:main Oct 5, 2025
11 checks passed
@ShaharNaveh

Copy link
Copy Markdown
Contributor Author

I am worrying about the newly introduced magic numbers. I wish it could be quickly resolved in next patch

I'll send a quick patch to resolve it in the next couple of days

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.

2 participants