diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-12-11 06:28:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-11 06:28:18 (GMT) |
commit | bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d (patch) | |
tree | b9dbe54e2c1380294f3e2396450132d5b205af0a /Objects/object.c | |
parent | 7cf3d8e25174c8871883e42f3240fd7f01efd3a8 (diff) | |
download | cpython-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/object.c')
-rw-r--r-- | Objects/object.c | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/Objects/object.c b/Objects/object.c index c2d78aa..993342e 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1080,23 +1080,6 @@ PyObject_SelfIter(PyObject *obj) return obj; } -/* Convenience function to get a builtin from its name */ -PyObject * -_PyObject_GetBuiltin(const char *name) -{ - PyObject *mod_name, *mod, *attr; - - mod_name = _PyUnicode_FromId(&PyId_builtins); /* borrowed */ - if (mod_name == NULL) - return NULL; - mod = PyImport_Import(mod_name); - if (mod == NULL) - return NULL; - attr = PyObject_GetAttrString(mod, name); - Py_DECREF(mod); - return attr; -} - /* Helper used when the __next__ method is removed from a type: tp_iternext is never NULL and can be safely called without checking on every iteration. |