[issue29507] Use FASTCALL in call_method() to avoid temporary tuple

STINNER Victor report at bugs.python.org
Thu Feb 9 17:22:20 EST 2017


STINNER Victor added the comment:

Naoki: "method_fastcall4.patch looks clean enough, and performance benefit seems nice."

Ok, I pushed the patch with minor changes:

* replace "variants:" with "Variants:"
* rename lookup_maybe_unbound() to lookup_maybe_method()
* rename lookup_method_unbound() to lookup_method()


"I don't know current test suite covers unusual special methods."

What do you mean by "unusual special methods"?


"Maybe, we can extend test_class to cover !unbound (e.g. @classmethod) case."

It's hard to test all cases, since they are a lot of function types in Python, and each slot (wrapper in typeobject.c) has its own C implementation.

But yeah, in general more tests don't harm :-)

Since the patch here optimizes the most common case, a regular method implemented in Python, I didn't add a specific test with the change. This case is already very well tested, like everything in the stdlib, no?

--

I tried to imagine how we could avoid temporary method objects in more cases like Python class methods (using @classmethod), but I don't think that it's worth it.

It would require more complex code for a less common case. Or do someone see other common cases which would benefit of a similar optimization?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29507>
_______________________________________


More information about the Python-bugs-list mailing list