[issue46533] Specialize for staticmethods and classmethods

2022-01-28 Thread Mark Shannon
Change by Mark Shannon : -- keywords: +patch pull_requests: +29169 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30990 ___ Python tracker ___

[issue46533] Specialize for staticmethods and classmethods

2022-01-26 Thread Ken Jin
Ken Jin added the comment: Ah woops, my bad, I mixed up the two concepts. Thanks for the thorough explanation here! -- ___ Python tracker ___

[issue46533] Specialize for staticmethods and classmethods

2022-01-26 Thread Mark Shannon
Mark Shannon 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 > >>> C().m > So,

[issue46533] Specialize for staticmethods and classmethods

2022-01-26 Thread Ken Jin
Ken Jin added the comment: Slightly off topic rambling: My own toy attempts at classmethod specialization suggested that it barely sped anything up. Most of the time went to creation of the new classmethod object. I'd imagine supporting Py_TPFLAGS_METHOD_DESCRIPTOR would speed things up,

[issue46533] Specialize for staticmethods and classmethods

2022-01-26 Thread Mark Shannon
New submission from Mark Shannon : Calls of the form `x.m(args)` where either `x = X` or x = X()` and X is a class, and `m` is a classmethod or staticmethod are not currently specialized. Typically the `x.m()` will translate to: LOAD_FAST x LOAD_METHOD "m" PRECALL_METHOD 0 CALL 0 Since