Message287371
Subset of the (almost) rejected issue #29259 (tp_fastcall), attached patch adds _PyMethod_FastCall() and uses it in call_method() of typeobject.c. The change avoids the creation of a temporary tuple for Python functions and METH_FASTCALL C functions.
Currently, call_method() calls method_call() which calls _PyObject_Call_Prepend(), and calling method_call() requires a tuple for positional arguments.
Example of benchmark on __getitem__(): 1.3x faster (-22%).
$ ./python -m perf timeit -s 'class C:' -s ' def __getitem__(self, index): return index' -s 'c=C()' 'c[0]'
Median +- std dev: 130 ns +- 1 ns => 102 ns +- 1 ns
See also the issue #29263 "Implement LOAD_METHOD/CALL_METHOD for C functions". |
|
Date |
User |
Action |
Args |
2017-02-09 00:17:38 | vstinner | set | recipients:
+ vstinner, methane, serhiy.storchaka |
2017-02-09 00:17:38 | vstinner | set | messageid: <1486599458.19.0.87442756928.issue29507@psf.upfronthosting.co.za> |
2017-02-09 00:17:38 | vstinner | link | issue29507 messages |
2017-02-09 00:17:38 | vstinner | create | |
|