mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
gh-131738: optimize builtin any/all/tuple calls with a generator expression arg (#131737)
This commit is contained in:
parent
674dbf3b3a
commit
2c8f329dc6
16 changed files with 199 additions and 38 deletions
|
@ -790,6 +790,26 @@ pycore_init_builtins(PyThreadState *tstate)
|
|||
}
|
||||
interp->callable_cache.len = len;
|
||||
|
||||
PyObject *all = PyDict_GetItemWithError(builtins_dict, &_Py_ID(all));
|
||||
if (!all) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
PyObject *any = PyDict_GetItemWithError(builtins_dict, &_Py_ID(any));
|
||||
if (!any) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
interp->common_consts[CONSTANT_ASSERTIONERROR] = PyExc_AssertionError;
|
||||
interp->common_consts[CONSTANT_NOTIMPLEMENTEDERROR] = PyExc_NotImplementedError;
|
||||
interp->common_consts[CONSTANT_BUILTIN_TUPLE] = (PyObject*)&PyTuple_Type;
|
||||
interp->common_consts[CONSTANT_BUILTIN_ALL] = all;
|
||||
interp->common_consts[CONSTANT_BUILTIN_ANY] = any;
|
||||
|
||||
for (int i=0; i < NUM_COMMON_CONSTANTS; i++) {
|
||||
assert(interp->common_consts[i] != NULL);
|
||||
}
|
||||
|
||||
PyObject *list_append = _PyType_Lookup(&PyList_Type, &_Py_ID(append));
|
||||
if (list_append == NULL) {
|
||||
goto error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue