mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +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
|
@ -4437,6 +4437,20 @@ PyEval_GetBuiltins(void)
|
|||
return current_frame->f_builtins;
|
||||
}
|
||||
|
||||
/* Convenience function to get a builtin from its name */
|
||||
PyObject *
|
||||
_PyEval_GetBuiltinId(_Py_Identifier *name)
|
||||
{
|
||||
PyObject *attr = _PyDict_GetItemIdWithError(PyEval_GetBuiltins(), name);
|
||||
if (attr) {
|
||||
Py_INCREF(attr);
|
||||
}
|
||||
else if (!PyErr_Occurred()) {
|
||||
PyErr_SetObject(PyExc_AttributeError, _PyUnicode_FromId(name));
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyEval_GetLocals(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue