From bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 11 Dec 2018 08:28:18 +0200 Subject: 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". --- Modules/itertoolsmodule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Modules/itertoolsmodule.c') diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 89c0280c9d..581ae2c67e 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -368,8 +368,9 @@ _grouper_next(_grouperobject *igo) static PyObject * _grouper_reduce(_grouperobject *lz, PyObject *Py_UNUSED(ignored)) { + _Py_IDENTIFIER(iter); if (((groupbyobject *)lz->parent)->currgrouper != lz) { - return Py_BuildValue("N(())", _PyObject_GetBuiltin("iter")); + return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter)); } return Py_BuildValue("O(OO)", Py_TYPE(lz), lz->parent, lz->tgtkey); } -- cgit v1.2.1