On Tue, Jun 30, 2020 at 6:45 AM Raymond Hettinger firstname.lastname@example.org wrote:
Converting macros to static inline functions should only impact very few C extensions which use macros in unusual ways.
These should be individually verified to make sure they actually get inlined by the compiler. In https://bugs.python.org/issue39542 about nine PRs were applied without review or discussion. One of those, https://github.com/python/cpython/pull/18364 , converted PyType_Check() to static inline function but I'm not sure that it actually does get inlined. That may be the reason named tuple attribute access slowed by about 25% between Python 3.8 and Python 3.9.¹ Presumably, that PR also affected every single type check in the entire C codebase and will affect third-party extensions as well.
I confirmed the performance regression, although the difference is 12%. And I find the commit cause the regression.
The regression is not caused by "static inline" function is not inlined by compiler. The commit changed PyType_HasFeature to call regular function PyType_GetFlags always.