This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients pitrou, serhiy.storchaka, vstinner
Date 2017-05-30.14:00:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496152833.78.0.366523958895.issue30509@psf.upfronthosting.co.za>
In-reply-to
Content
> type-slot-calls.diff: Can you please create a pull request?

I provided just a patch because I expected that you perhaps will want to play with it and propose alternative patch. It is simpler to compare patches with Rietveld than on GitHub. But if you prefer, I'll make a PR.

> Hum, can you please post a microbenchmark results to see the effect of the patch?

$ cat x.py
class A(object):
    def __add__(self, other):
        return 42

$ ./python -m perf timeit -s 'from x import A; a = A(); b = A()' --duplicate 100 'a.__add__(b)'
Unpatched:  Mean +- std dev: 256 ns +- 9 ns
Patched:    Mean +- std dev: 255 ns +- 10 ns

$ ./python -m perf timeit -s 'from x import A; a = A(); b = A()' --duplicate 100 'a + b'
Unpatched:  Mean +- std dev: 332 ns +- 10 ns
Patched:    Mean +- std dev: 286 ns +- 5 ns

> * the calling convention of the Python C API requires to create a tuple, and that's expensive

It also makes other optimizations, like avoiding using varargs and creating immediate method object. All this already is applied as side effects of your changes.

* "a + b" has a complex semantics which requires to check for __radd__, check for issubclass(), etc.

Since a and b have the same type the complex semantic doesn't play a role here.
History
Date User Action Args
2017-05-30 14:00:33serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, vstinner
2017-05-30 14:00:33serhiy.storchakasetmessageid: <1496152833.78.0.366523958895.issue30509@psf.upfronthosting.co.za>
2017-05-30 14:00:33serhiy.storchakalinkissue30509 messages
2017-05-30 14:00:33serhiy.storchakacreate