Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use a correct and transparent definition of "code unit" in C code #100222

Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)
@markshannon

Description

@markshannon

We should define_Py_CODEUNIT properly without the need for type punning.

Currently_Py_CODEUNIT is define astypedef uint16_t _Py_CODEUNIT; but it really an 8 bit opcode followed a bit operand aligned to 16 bits. Which means we need to resort to type punning to access the operand and oparg individually.
E.g.https://github.com/python/cpython/blob/main/Include/cpython/code.h#L32

PEP 7 states that "Python 3.11 and newer versions use C11 without optional_features".
So let's use a union with anonymous struct to define it properly:

typedefunion {int16_talign;struct {uint8_topcode;uint8_toparg;    };}_Py_CODEUNIT;

@iritkatriel thoughts?

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp