[issue45295] _PyObject_GetMethod/LOAD_METHOD for C classmethods

2021-09-27 Thread Ken Jin


Change by Ken Jin :


--
keywords: +patch
pull_requests: +26961
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28572

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45295] _PyObject_GetMethod/LOAD_METHOD for C classmethods

2021-09-26 Thread Ken Jin


New submission from Ken Jin :

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:
200 loops, best of 5: 107 nsec per loop
Patched:
500 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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com