Message411737
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. |
|
Date |
User |
Action |
Args |
2022-01-26 11:11:01 | Mark.Shannon | set | recipients:
+ Mark.Shannon, kj |
2022-01-26 11:11:01 | Mark.Shannon | set | messageid: <1643195461.79.0.974638487251.issue46533@roundup.psfhosted.org> |
2022-01-26 11:11:01 | Mark.Shannon | link | issue46533 messages |
2022-01-26 11:11:01 | Mark.Shannon | create | |
|