New submission from Ken Jin <kenjin4...@gmail.com>:
LOAD_METHOD + CALL_METHOD currently doesn't work for Python @classmethod and C classmethod (METH_CLASS). They still create bound classmethods which are fairly expensive. I propose supporting classmethods. I have an implementation for C classmethods. It passes most of the test suite, and I've also got it to play along with PEP 659 specialization. Some numbers from Windows release build (PGO build will likely be less favorable): python.exe -m timeit "int.from_bytes(b'')" Main: 2000000 loops, best of 5: 107 nsec per loop Patched: 5000000 loops, best of 5: 72.4 nsec per loop Funnily enough, `(1).from_bytes()` still needs a bound classmethod, but I think people usually use the other form. A toy PR will be up for review. I will then split the change into two parts (one for _PyObject_GetMethod changes, another for PEP 659 specialization) to help decide if the maintenance-perf ratio is worth it. ---------- components: Interpreter Core messages: 402668 nosy: kj priority: normal severity: normal status: open title: _PyObject_GetMethod/LOAD_METHOD for C classmethods type: performance versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45295> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com