Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Micro-benchmark results for PEP 580.
See https://github.com/jdemeyer/callbench for benchmarking code
CPython was configured with --enable-optimizations and compiled with GCC 6.4.0.
CPython 1fc5bf2ff PEP 580 1fc5bf2ff PEP 590 2f54908af
VARARGS function(): 24.5 ns +- 0.1 ns 24.7 ns +- 0.2 ns 25.9 ns +- 0.4 ns
FASTCALL function(): 19.3 ns +- 0.9 ns 17.3 ns +- 0.2 ns 19.4 ns +- 0.4 ns
VARARGS obj.method(): 41.9 ns +- 0.2 ns 41.3 ns +- 0.8 ns 42.1 ns +- 0.8 ns
FASTCALL obj.method(): 34.9 ns +- 0.7 ns 33.8 ns +- 0.6 ns 35.6 ns +- 0.5 ns
VARARGS bound method(): 24.4 ns +- 0.1 ns 24.7 ns +- 0.1 ns 25.8 ns +- 0.4 ns
FASTCALL bound method(): 19.5 ns +- 0.8 ns 17.6 ns +- 0.3 ns 19.1 ns +- 0.4 ns
VARARGS cls.method(obj, ): 52.0 ns +- 0.7 ns 49.3 ns +- 0.6 ns 52.8 ns +- 0.7 ns
FASTCALL cls.method(obj, ): 44.0 ns +- 0.6 ns 42.7 ns +- 1.1 ns 43.8 ns +- 1.0 ns
VARARGS unbound method(obj, ): 30.6 ns +- 0.3 ns 30.6 ns +- 0.5 ns 31.9 ns +- 0.7 ns
FASTCALL unbound method(obj, ): 24.2 ns +- 0.2 ns 23.1 ns +- 0.2 ns 25.2 ns +- 0.3 ns
tp_call(): 21.2 ns +- 0.6 ns 21.7 ns +- 0.4 ns 21.1 ns +- 0.3 ns
VARARGS function(1, 2, 3): 46.1 ns +- 0.3 ns 46.8 ns +- 1.0 ns 47.4 ns +- 1.2 ns
FASTCALL function(1, 2, 3): 26.8 ns +- 0.4 ns 25.5 ns +- 0.1 ns 27.8 ns +- 0.2 ns
VARARGS obj.method(1, 2, 3): 66.2 ns +- 1.0 ns 65.1 ns +- 0.5 ns 65.5 ns +- 0.7 ns
FASTCALL obj.method(1, 2, 3): 43.6 ns +- 0.5 ns 42.8 ns +- 1.0 ns 43.7 ns +- 1.1 ns
VARARGS bound method(1, 2, 3): 46.1 ns +- 0.4 ns 46.5 ns +- 1.0 ns 47.4 ns +- 0.8 ns
FASTCALL bound method(1, 2, 3): 26.6 ns +- 0.2 ns 25.5 ns +- 0.4 ns 27.9 ns +- 0.3 ns
VARARGS cls.method(obj, 1, 2, 3): 76.5 ns +- 0.4 ns 73.6 ns +- 0.9 ns 79.7 ns +- 1.9 ns
FASTCALL cls.method(obj, 1, 2, 3): 52.6 ns +- 0.7 ns 51.4 ns +- 0.9 ns 54.5 ns +- 1.5 ns
VARARGS unbound method(obj, 1, 2, 3): 54.9 ns +- 1.0 ns 52.2 ns +- 0.7 ns 55.3 ns +- 0.7 ns
FASTCALL unbound method(obj, 1, 2, 3): 33.5 ns +- 0.3 ns 31.0 ns +- 0.3 ns 34.0 ns +- 0.9 ns
tp_call(1, 2, 3): 43.7 ns +- 0.5 ns 42.5 ns +- 3.2 ns 43.8 ns +- 1.3 ns
VARARGS function(1, two=2): 90.9 ns +- 1.2 ns 87.0 ns +- 1.0 ns 89.6 ns +- 0.8 ns
FASTCALL function(1, two=2): 29.1 ns +- 0.2 ns 28.4 ns +- 0.4 ns 29.6 ns +- 0.2 ns
VARARGS obj.method(1, two=2): 120 ns +- 1 ns 120 ns +- 1 ns 123 ns +- 1 ns
FASTCALL obj.method(1, two=2): 55.4 ns +- 1.2 ns 57.2 ns +- 1.4 ns 55.7 ns +- 0.6 ns
VARARGS bound method(1, two=2): 90.6 ns +- 0.5 ns 86.7 ns +- 0.4 ns 89.6 ns +- 0.8 ns
FASTCALL bound method(1, two=2): 29.1 ns +- 0.1 ns 28.6 ns +- 0.5 ns 29.6 ns +- 0.1 ns
VARARGS cls.method(obj, 1, two=2): 115 ns +- 1 ns 114 ns +- 1 ns 114 ns +- 1 ns
FASTCALL cls.method(obj, 1, two=2): 50.5 ns +- 0.4 ns 50.7 ns +- 0.8 ns 52.2 ns +- 2.4 ns
VARARGS unbound method(obj, 1, two=2): 96.2 ns +- 0.7 ns 96.2 ns +- 0.5 ns 99.7 ns +- 0.6 ns
FASTCALL unbound method(obj, 1, two=2): 35.2 ns +- 0.2 ns 34.6 ns +- 1.2 ns 36.4 ns +- 0.2 ns
tp_call(1, two=2): 83.2 ns +- 1.0 ns 85.3 ns +- 3.7 ns 84.1 ns +- 0.5 ns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.