| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Improve performance of attribute lookups on objects with custom ``__getattribute__`` and ``__getattr__``. Patch by Ken Jin. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7782,10 +7782,17 @@ slot_tp_getattro(PyObject *self, PyObject *name) | |||
| 7782 | 7782 | return vectorcall_method(&_Py_ID(__getattribute__), stack, 2); | |
| 7783 | 7783 | } | |
| 7784 | 7784 | ||
| 7785 | - static PyObject * | ||
| 7785 | + static inline PyObject * | ||
| 7786 | 7786 | call_attribute(PyObject *self, PyObject *attr, PyObject *name) | |
| 7787 | 7787 | { | |
| 7788 | 7788 | PyObject *res, *descr = NULL; | |
| 7789 | + | ||
| 7790 | + if (_PyType_HasFeature(Py_TYPE(attr), Py_TPFLAGS_METHOD_DESCRIPTOR)) { | ||
| 7791 | + PyObject *args[] = { self, name }; | ||
| 7792 | + res = PyObject_Vectorcall(attr, args, 2, NULL); | ||
| 7793 | + return res; | ||
| 7794 | + } | ||
| 7795 | + | ||
| 7789 | 7796 | descrgetfunc f = Py_TYPE(attr)->tp_descr_get; | |
| 7790 | 7797 | ||
| 7791 | 7798 | if (f != NULL) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments