I briefly looked at this. New user so I can only post answers, not comments yet. PyQt5 is built with SIP and at a very initial glance it looks like SIP might enumerate method implementations in advance and store them in a table of pointers.
It's possible that __getattribute__
isn't being invoked because SIP is avoiding the infrastructure that does this, as PyQt was designed decades ago when such highly efficient optimizations were really valued. However, this infrastructure has changed over releases, and there's a little value to making sure your Python and PyQt releases are up-to-date.
SIP has its own functionality for tracing functions but using this would likely mean rebuilding PyQt5 from its source.
It may be appropriate here to write a script to enumerate every possible method and generate tracing stubs. This is so useful for using PyQt that it may already exist somewhere. This is also the approach taken by SIP. All of these functions appear to me to be enumerated in site-packages/PyQt5/QtWidgets.pyi and are likely also visible with runtime introspection (dir(QWidget)
, import inspect; inspect.signature(method)
).
I'm afraid I do not have a Qt-compatible python interpreter right now to give a properly tested answer here, and this answer likely contains mistakes.