mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -452,14 +452,9 @@ descr_get_qualname(PyDescrObject *descr, void *Py_UNUSED(ignored))
|
|||
static PyObject *
|
||||
descr_reduce(PyDescrObject *descr, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
PyObject *builtins;
|
||||
PyObject *getattr;
|
||||
_Py_IDENTIFIER(getattr);
|
||||
|
||||
builtins = PyEval_GetBuiltins();
|
||||
getattr = _PyDict_GetItemId(builtins, &PyId_getattr);
|
||||
return Py_BuildValue("O(OO)", getattr, PyDescr_TYPE(descr),
|
||||
PyDescr_NAME(descr));
|
||||
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr),
|
||||
PyDescr_TYPE(descr), PyDescr_NAME(descr));
|
||||
}
|
||||
|
||||
static PyMethodDef descr_methods[] = {
|
||||
|
@ -1087,13 +1082,9 @@ wrapper_repr(wrapperobject *wp)
|
|||
static PyObject *
|
||||
wrapper_reduce(wrapperobject *wp, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
PyObject *builtins;
|
||||
PyObject *getattr;
|
||||
_Py_IDENTIFIER(getattr);
|
||||
|
||||
builtins = PyEval_GetBuiltins();
|
||||
getattr = _PyDict_GetItemId(builtins, &PyId_getattr);
|
||||
return Py_BuildValue("O(OO)", getattr, wp->self, PyDescr_NAME(wp->descr));
|
||||
return Py_BuildValue("N(OO)", _PyEval_GetBuiltinId(&PyId_getattr),
|
||||
wp->self, PyDescr_NAME(wp->descr));
|
||||
}
|
||||
|
||||
static PyMethodDef wrapper_methods[] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue