You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use a correct and transparent definition of "code unit" in C code #100222
We should define _Py_CODEUNIT properly without the need for type punning.
Currently _Py_CODEUNIT is define as typedef 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:
Activity
iritkatriel commentedon Dec 13, 2022
Looks good, would it be a drop-in replacement?
markshannon commentedon Dec 13, 2022
Depends on how you define "drop-in"
GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of c…
Merge branch 'main' into typedocs
GH-100222: fix typo _py_set_opocde -> _py_set_opcode (GH-100259)
Merge branch 'main' into fastmock