mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
bpo-35444: Unify and optimize the helper for getting a builtin object. (GH-11047)
This speeds up pickling of some iterators. This fixes also error handling in pickling methods when fail to look up builtin "getattr".
This commit is contained in:
parent
7cf3d8e251
commit
bb86bf4c4e
21 changed files with 68 additions and 72 deletions
|
|
@ -842,6 +842,7 @@ static PyObject *setiter_iternext(setiterobject *si);
|
|||
static PyObject *
|
||||
setiter_reduce(setiterobject *si, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
_Py_IDENTIFIER(iter);
|
||||
/* copy the iterator state */
|
||||
setiterobject tmp = *si;
|
||||
Py_XINCREF(tmp.si_set);
|
||||
|
|
@ -852,7 +853,7 @@ setiter_reduce(setiterobject *si, PyObject *Py_UNUSED(ignored))
|
|||
if (list == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("N(N)", _PyObject_GetBuiltin("iter"), list);
|
||||
return Py_BuildValue("N(N)", _PyEval_GetBuiltinId(&PyId_iter), list);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue