summaryrefslogtreecommitdiffstats
path: root/Objects/methodobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-12-11 06:28:18 (GMT)
committerGitHub <noreply@github.com>2018-12-11 06:28:18 (GMT)
commitbb86bf4c4eaa30b1f5192dab9f389ce0bb61114d (patch)
treeb9dbe54e2c1380294f3e2396450132d5b205af0a /Objects/methodobject.c
parent7cf3d8e25174c8871883e42f3240fd7f01efd3a8 (diff)
downloadcpython-bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d.zip
cpython-bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d.tar.gz
cpython-bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d.tar.bz2
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".
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r--Objects/methodobject.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 6dec642..9fed3fc 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -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[] = {