mirror of
https://github.com/python/cpython.git
synced 2026-06-21 10:34:26 -04:00
gh-148871: Add CONSTANT_EMPTY_TUPLE to LOAD_COMMON_CONSTANT (GH-149688)
This commit is contained in:
@@ -1468,6 +1468,10 @@ maybe_instr_make_load_common_const(cfg_instr *instr, PyObject *newconst)
|
||||
&& PyUnicode_GET_LENGTH(newconst) == 0) {
|
||||
oparg = CONSTANT_EMPTY_STR;
|
||||
}
|
||||
else if (PyTuple_CheckExact(newconst)
|
||||
&& PyTuple_GET_SIZE(newconst) == 0) {
|
||||
oparg = CONSTANT_EMPTY_TUPLE;
|
||||
}
|
||||
else if (PyLong_CheckExact(newconst)) {
|
||||
int overflow;
|
||||
long val = PyLong_AsLongAndOverflow(newconst, &overflow);
|
||||
|
||||
@@ -893,6 +893,8 @@ pycore_init_builtins(PyThreadState *tstate)
|
||||
interp->common_consts[CONSTANT_MINUS_ONE] =
|
||||
(PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS - 1];
|
||||
interp->common_consts[CONSTANT_BUILTIN_FROZENSET] = (PyObject *)&PyFrozenSet_Type;
|
||||
interp->common_consts[CONSTANT_EMPTY_TUPLE] =
|
||||
Py_GetConstantBorrowed(Py_CONSTANT_EMPTY_TUPLE);
|
||||
for (int i = 0; i < NUM_COMMON_CONSTANTS; i++) {
|
||||
assert(interp->common_consts[i] != NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user