diff options
author | INADA Naoki <methane@users.noreply.github.com> | 2018-01-16 11:52:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-16 11:52:41 (GMT) |
commit | 378edee0a3b913d60653dc17dfe61d83405a8135 (patch) | |
tree | e91c9b9b446aa0ce076da778bde6c1da27ff5e23 /Misc/NEWS.d/next | |
parent | b44c5169f64178d2ff2914187b315549e7ab0cb6 (diff) | |
download | cpython-378edee0a3b913d60653dc17dfe61d83405a8135.zip cpython-378edee0a3b913d60653dc17dfe61d83405a8135.tar.gz cpython-378edee0a3b913d60653dc17dfe61d83405a8135.tar.bz2 |
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 'Misc/NEWS.d/next')
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2018-01-16-18-51-58.bpo-32544.ga-cFE.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-01-16-18-51-58.bpo-32544.ga-cFE.rst b/Misc/NEWS.d/next/Core and Builtins/2018-01-16-18-51-58.bpo-32544.ga-cFE.rst new file mode 100644 index 0000000..55a52fa --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2018-01-16-18-51-58.bpo-32544.ga-cFE.rst @@ -0,0 +1,3 @@ +``hasattr(obj, name)`` and ``getattr(obj, name, default)`` are about 4 times +faster than before when ``name`` is not found and ``obj`` doesn't override +``__getattr__`` or ``__getattribute__``. |