mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +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
|
|
@ -78,8 +78,6 @@ method_reduce(PyMethodObject *im, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
PyObject *self = PyMethod_GET_SELF(im);
|
||||
PyObject *func = PyMethod_GET_FUNCTION(im);
|
||||
PyObject *builtins;
|
||||
PyObject *getattr;
|
||||
PyObject *funcname;
|
||||
_Py_IDENTIFIER(getattr);
|
||||
|
||||
|
|
@ -87,9 +85,8 @@ method_reduce(PyMethodObject *im, PyObject *Py_UNUSED(ignored))
|
|||
if (funcname == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
builtins = PyEval_GetBuiltins();
|
||||
getattr = _PyDict_GetItemId(builtins, &PyId_getattr);
|
||||
return Py_BuildValue("O(ON)", getattr, self, funcname);
|
||||
return Py_BuildValue("N(ON)", _PyEval_GetBuiltinId(&PyId_getattr),
|
||||
self, funcname);
|
||||
}
|
||||
|
||||
static PyMethodDef method_methods[] = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue