Message 285457 - Python tracker (original) (raw)

This is proof of concept patch to support LOAD_METHOD & CALL_METHOD for METH_FASTCALL methods. (This patch should be applied after fastcall.patch)

$ ./python -m perf timeit --compare-to pwd/python-fastcall -s "d = b''" -- "d.decode()" python-fastcall: ..................... 91.0 ns +- 1.0 ns python: ..................... 80.3 ns +- 0.3 ns

Median +- std dev: [python-fastcall] 91.0 ns +- 1.0 ns -> [python] 80.3 ns +- 0.3 ns: 1.13x faster

$ ./python -m perf timeit --compare-to pwd/python-fastcall -s "d = b''" -- "d.decode('ascii')" python-fastcall: ..................... 116 ns +- 1 ns python: ..................... 106 ns +- 1 ns

Median +- std dev: [python-fastcall] 116 ns +- 1 ns -> [python] 106 ns +- 1 ns: 1.10x faster

Since PyCFunction is lighter than PyMethodObject, performance benefit seems smaller than Python method (up to 20%).

Sadly speaking, there are only few METH_FASTCALL in builtin type.