Mark Shannon <m...@hotpy.org> added the comment:

For classmethods, I expect the savings to come from not creating a bound-method 
and from better specialization of the following call.

classmethod case:

>>> class C:
...     @classmethod
...     def m(*args):
...          pass
... 
>>> C.m
<bound method C.m of <class '__main__.C'>>
>>> C().m
<bound method C.m of <class '__main__.C'>>

So, without specialization LOAD_METHOD "m" has the following stack effect (with 
`x = C()`):
x -> NULL <bound method>
C -> NULL <bound method>
With specialization:
x -> C <function>
C -> C <function>

For static methods the saving is less as there is no change in stack effect, 
but we do save the lookup, and we can reuse existing bytecodes.


Neither classmethod or staticmethod should have Py_TPFLAGS_METHOD_DESCRIPTOR 
set, as they have different semantics.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46533>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to