mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00: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
|
@ -104,16 +104,13 @@ meth_dealloc(PyCFunctionObject *m)
|
|||
static PyObject *
|
||||
meth_reduce(PyCFunctionObject *m, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
PyObject *builtins;
|
||||
PyObject *getattr;
|
||||
_Py_IDENTIFIER(getattr);
|
||||
|
||||
if (m->m_self == NULL || PyModule_Check(m->m_self))
|
||||
return PyUnicode_FromString(m->m_ml->ml_name);
|
||||
|
||||
builtins = PyEval_GetBuiltins();
|
||||
getattr = _PyDict_GetItemId(builtins, &PyId_getattr);
|
||||
return Py_BuildValue("O(Os)", getattr, m->m_self, m->m_ml->ml_name);
|
||||
return Py_BuildValue("N(Os)", _PyEval_GetBuiltinId(&PyId_getattr),
|
||||
m->m_self, m->m_ml->ml_name);
|
||||
}
|
||||
|
||||
static PyMethodDef meth_methods[] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue