Skip to content

Commit c5cd49e

Browse files
committed
add also CONSTANT_BUILTIN_ALL/ANY
1 parent 0911a01 commit c5cd49e

7 files changed

Lines changed: 57 additions & 10 deletions

File tree

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_opcode_utils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ extern "C" {
6868
#define CONSTANT_ASSERTIONERROR 0
6969
#define CONSTANT_NOTIMPLEMENTEDERROR 1
7070
#define CONSTANT_BUILTIN_TUPLE 2
71-
#define NUM_COMMON_CONSTANTS 3
71+
#define CONSTANT_BUILTIN_ALL 3
72+
#define CONSTANT_BUILTIN_ANY 4
73+
#define NUM_COMMON_CONSTANTS 5
7274

7375
/* Values used in the oparg for RESUME */
7476
#define RESUME_AT_FUNC_START 0

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/opcode.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
_intrinsic_1_descs = _opcode.get_intrinsic1_descs()
4040
_intrinsic_2_descs = _opcode.get_intrinsic2_descs()
4141
_special_method_names = _opcode.get_special_method_names()
42-
_common_constants = [AssertionError, NotImplementedError, builtins.tuple]
42+
_common_constants = [AssertionError, NotImplementedError,
43+
builtins.tuple, builtins.all, builtins.any]
4344
_nb_ops = _opcode.get_nb_ops()
4445

4546
hascompare = [opmap["COMPARE_OP"]]

Python/bytecodes.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,10 +1412,18 @@ dummy_func(
14121412
else if (oparg == CONSTANT_NOTIMPLEMENTEDERROR) {
14131413
val = PyExc_NotImplementedError;
14141414
}
1415-
else {
1416-
assert(oparg == CONSTANT_BUILTIN_TUPLE);
1415+
else if (oparg == CONSTANT_BUILTIN_TUPLE) {
14171416
val = (PyObject*)&PyTuple_Type;
14181417
}
1418+
else if (oparg == CONSTANT_BUILTIN_ALL) {
1419+
val = PyDict_GetItemWithError(builtins_dict, &_Py_ID(all));
1420+
}
1421+
else if (oparg == CONSTANT_BUILTIN_ANY) {
1422+
val = PyDict_GetItemWithError(builtins_dict, &_Py_ID(any));
1423+
}
1424+
else {
1425+
Py_UNREACHABLE();
1426+
}
14191427
value = PyStackRef_FromPyObjectImmortal(val);
14201428
}
14211429

Python/executor_cases.c.h

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)