summaryrefslogtreecommitdiffstats
path: root/Objects/rangeobject.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/rangeobject.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/rangeobject.c')
-rw-r--r--Objects/rangeobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index e7b47bd..4b8e5ed 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -742,6 +742,7 @@ PyDoc_STRVAR(length_hint_doc,
static PyObject *
rangeiter_reduce(rangeiterobject *r, PyObject *Py_UNUSED(ignored))
{
+ _Py_IDENTIFIER(iter);
PyObject *start=NULL, *stop=NULL, *step=NULL;
PyObject *range;
@@ -760,7 +761,8 @@ rangeiter_reduce(rangeiterobject *r, PyObject *Py_UNUSED(ignored))
if (range == NULL)
goto err;
/* return the result */
- return Py_BuildValue("N(N)i", _PyObject_GetBuiltin("iter"), range, r->index);
+ return Py_BuildValue("N(N)i", _PyEval_GetBuiltinId(&PyId_iter),
+ range, r->index);
err:
Py_XDECREF(start);
Py_XDECREF(stop);
@@ -898,6 +900,7 @@ longrangeiter_len(longrangeiterobject *r, PyObject *no_args)
static PyObject *
longrangeiter_reduce(longrangeiterobject *r, PyObject *Py_UNUSED(ignored))
{
+ _Py_IDENTIFIER(iter);
PyObject *product, *stop=NULL;
PyObject *range;
@@ -921,7 +924,8 @@ longrangeiter_reduce(longrangeiterobject *r, PyObject *Py_UNUSED(ignored))
}
/* return the result */
- return Py_BuildValue("N(N)O", _PyObject_GetBuiltin("iter"), range, r->index);
+ return Py_BuildValue("N(N)O", _PyEval_GetBuiltinId(&PyId_iter),
+ range, r->index);
}
static PyObject *