mirror of
https://github.com/python/cpython.git
synced 2026-06-05 01:10:53 +00:00
gh-148871: Add CONSTANT_EMPTY_TUPLE to LOAD_COMMON_CONSTANT (GH-149688)
This commit is contained in:
parent
c35b0f2b62
commit
f2fa291db8
8 changed files with 20 additions and 9 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue