Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
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?