You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Performance of attribute lookup for type objects #92216
The reason seems to be that the type_getattro always executes PyErr_Format, wheras for the "normal" attribute lookup this is avoided (see here and here)
Notes:
The benchmark is from the python side, but we are working with the C-API
Related to this issue, I am wondering if we can consider _PyObject_LookupAttr either as stable (removing the _) or as "semi stable"?
Of course that is only faster currently for the default tp_getattro, but I suspect that is a huge amount of calls.
EDIT: Ah, I half thought it was not fully internal API right now, but "semi" exposed.
Activity
seberg commentedon May 3, 2022
Related to this issue, I am wondering if we can consider
_PyObject_LookupAttreither as stable (removing the_) or as "semi stable"?Of course that is only faster currently for the default
tp_getattro, but I suspect that is a huge amount of calls.EDIT: Ah, I half thought it was not fully internal API right now, but "semi" exposed.
eendebakpt commentedon May 3, 2022
Also see: #76752 (PRs where
_PyObject_LookupAttris introduced)serhiy-storchaka commentedon May 4, 2022
_PyObject_LookupAttris an internal API.I'll look if it is possible to speed up lookup of the absent attribute in a class object.
PERF: Skip probing `__array_ufunc__` for NumPy builtin scalars (#21470)
gh-92216: improve performance of `hasattr` for type objects (GH-99979)
Fidget-Spinner commentedon Dec 23, 2022
@eendebakpt thanks for the improvement. Can I close this issue now or do you plan to submit more PRs?
eendebakpt commentedon Dec 23, 2022
The issue is solved, i will close
Merged main into regmachine branch (#50)