mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-102213: Optimize the performance of __getattr__
(GH-102248)
When __getattr__ is defined, python with try to find an attribute using _PyObject_GenericGetAttrWithDict find nothing is reasonable so we don't need an exception, it will hurt performance.
This commit is contained in:
parent
5ffdaf748d
commit
aa0a73d1bc
4 changed files with 14 additions and 3 deletions
|
@ -1405,6 +1405,12 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
|
|||
return _PyObject_GenericGetAttrWithDict(obj, name, NULL, 0);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
_PyObject_GenericTryGetAttr(PyObject *obj, PyObject *name)
|
||||
{
|
||||
return _PyObject_GenericGetAttrWithDict(obj, name, NULL, 1);
|
||||
}
|
||||
|
||||
int
|
||||
_PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
|
||||
PyObject *value, PyObject *dict)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue