Skip to content

Changes to specialized instructions requires a magic number change. #109256

Closed
@markshannon

Description

@markshannon

Until #107971 only changes to the set of instructions present in the pyc file required a new version change.
Now, removing or adding any opcode requires a pyc file.
There are a few problems with this.

  • pyc files have to be regenerated for changes unrelated to the on disk format.
  • This makes it much harder to add or remove specializations during the beta phase, as it will invalidate pyc files
  • It consumes an unnecessary number of magic numbers. This is not a big deal, but want to keep to a limit of 50 per release
  • It reduces stability in layout and thus performance, making meaningful benchmarking harder.
  • It is even easier to forget the magic number bump segfault on main for "./python.exe -m blurb" #109198

Proposal

Allocate "external" opcodes to odd numbers.
Allocate instrumented opcodes to the top region (as we do now)
Allocate specialized and other internal opcodes to even numbers

It would also be nice to be able to specify the most common opcodes, so that tooling does a decent job of laying out the tables.

We might also consider generating a hash of the opcodes and checking it test_opcodes to ensure that the magic number is updated when necessary.

@iritkatriel

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions