Skip to content

Commit

Permalink
PEP 505!!! (fix augmented assignments)
Browse files Browse the repository at this point in the history
  • Loading branch information
thatbirdguythatuknownot committed Oct 20, 2023
1 parent 8d09d4a commit 6eff0fd
Show file tree
Hide file tree
Showing 12 changed files with 328 additions and 85 deletions.
24 changes: 12 additions & 12 deletions Include/internal/pycore_opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 25 additions & 13 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 22 additions & 20 deletions Include/opcode_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ def def_op(name, op):
def_op('RESUME', 151) # This must be kept in sync with deepfreeze.py
def_op('MATCH_CLASS', 152)

def_op('POP_POPJUMP_IF_NONE', 153)
def_op('POP_POP2JUMP_IF_NONE', 154)

def_op('BUILD_CONST_KEY_MAP', 156)
def_op('BUILD_STRING', 157)
def_op('CONVERT_VALUE', 158)
Expand All @@ -180,6 +177,11 @@ def def_op(name, op):
def_op('LOAD_FROM_DICT_OR_DEREF', 176)
def_op('SET_FUNCTION_ATTRIBUTE', 177) # Attribute

def_op('POP_POPJUMP_IF_NONE', 180)
def_op('POP_POP2JUMP_IF_NONE', 181)
def_op('POP_POP3JUMP_IF_NONE', 182)
def_op('POP_POP4JUMP_IF_NONE', 183)

# Optimizer hook
def_op('ENTER_EXECUTOR', 230)

Expand Down
25 changes: 12 additions & 13 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2288,19 +2288,10 @@ dummy_func(
JUMPBY(oparg * Py_IsTrue(cond));
}

op(POP_POPJUMP_IF_TRUE, (unused if (jump), cond -- )) {
op(POP_IF_TRUE, (unused if (jump), cond -- cond)) {
assert(PyBool_Check(cond));
if (Py_IsTrue(cond)) {
STACK_SHRINK(2);
JUMPBY(oparg);
}
}

op(POP_POP2JUMP_IF_TRUE, (unused if (jump), unused if (jump), cond -- )) {
assert(PyBool_Check(cond));
if (Py_IsTrue(cond)) {
STACK_SHRINK(2);
JUMPBY(oparg);
STACK_SHRINK(1);
}
}

Expand All @@ -2316,9 +2307,17 @@ dummy_func(

macro(POP_JUMP_IF_NONE) = IS_NONE + POP_JUMP_IF_TRUE;

macro(POP_POPJUMP_IF_NONE) = IS_NONE + POP_POPJUMP_IF_TRUE;
macro(POP_POPJUMP_IF_NONE) =
IS_NONE + POP_IF_TRUE + POP_JUMP_IF_TRUE;

macro(POP_POP2JUMP_IF_NONE)
= IS_NONE + POP_IF_TRUE + POP_IF_TRUE + POP_JUMP_IF_TRUE;

macro(POP_POP3JUMP_IF_NONE)
= IS_NONE + POP_IF_TRUE + POP_IF_TRUE + POP_IF_TRUE + POP_JUMP_IF_TRUE;

macro(POP_POP2JUMP_IF_NONE) = IS_NONE + POP_POP2JUMP_IF_TRUE;
macro(POP_POP4JUMP_IF_NONE)
= IS_NONE + POP_IF_TRUE + POP_IF_TRUE + POP_IF_TRUE + POP_IF_TRUE + POP_JUMP_IF_TRUE;

macro(POP_JUMP_IF_NOT_NONE) = IS_NONE + POP_JUMP_IF_FALSE;

Expand Down
Loading

0 comments on commit 6eff0fd

Please sign in to comment.