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
|
@ -209,19 +209,15 @@ _Pickle_ClearState(PickleState *st)
|
|||
static int
|
||||
_Pickle_InitState(PickleState *st)
|
||||
{
|
||||
PyObject *builtins;
|
||||
PyObject *copyreg = NULL;
|
||||
PyObject *compat_pickle = NULL;
|
||||
PyObject *codecs = NULL;
|
||||
PyObject *functools = NULL;
|
||||
_Py_IDENTIFIER(getattr);
|
||||
|
||||
builtins = PyEval_GetBuiltins();
|
||||
if (builtins == NULL)
|
||||
goto error;
|
||||
st->getattr = PyDict_GetItemString(builtins, "getattr");
|
||||
st->getattr = _PyEval_GetBuiltinId(&PyId_getattr);
|
||||
if (st->getattr == NULL)
|
||||
goto error;
|
||||
Py_INCREF(st->getattr);
|
||||
|
||||
copyreg = PyImport_ImportModule("copyreg");
|
||||
if (!copyreg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue