summaryrefslogtreecommitdiff
path: root/Modules/_threadmodule.c
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2018-01-16 20:52:41 +0900
committerGitHub <noreply@github.com>2018-01-16 20:52:41 +0900
commit378edee0a3b913d60653dc17dfe61d83405a8135 (patch)
treee91c9b9b446aa0ce076da778bde6c1da27ff5e23 /Modules/_threadmodule.c
parentb44c5169f64178d2ff2914187b315549e7ab0cb6 (diff)
downloadcpython-git-378edee0a3b913d60653dc17dfe61d83405a8135.tar.gz
bpo-32544: Speed up hasattr() and getattr() (GH-5173)
AttributeError was raised always when attribute is not found. This commit skip raising AttributeError when `tp_getattro` is `PyObject_GenericGetAttr`. It makes hasattr() and getattr() about 4x faster when attribute is not found.
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r--Modules/_threadmodule.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index c9171f52e3..f594bda678 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -925,13 +925,15 @@ local_getattro(localobject *self, PyObject *name)
if (Py_TYPE(self) != &localtype)
/* use generic lookup for subtypes */
- return _PyObject_GenericGetAttrWithDict((PyObject *)self, name, ldict);
+ return _PyObject_GenericGetAttrWithDict(
+ (PyObject *)self, name, ldict, 0);
/* Optimization: just look in dict ourselves */
value = PyDict_GetItem(ldict, name);
if (value == NULL)
/* Fall back on generic to get __class__ and __dict__ */
- return _PyObject_GenericGetAttrWithDict((PyObject *)self, name, ldict);
+ return _PyObject_GenericGetAttrWithDict(
+ (PyObject *)self, name, ldict, 0);
Py_INCREF(value);
return value;