summaryrefslogtreecommitdiff
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-02-09 22:53:47 +0100
committerVictor Stinner <victor.stinner@gmail.com>2017-02-09 22:53:47 +0100
commit18bedc08c9a8216c93476e3da1cc4a3922d4cba6 (patch)
treee9d6d845a1e6e5a99e9a5ce02ba7c43e2f685a12 /Lib/test/test_exceptions.py
parent0e5f88f535c701c6090b355bb8ee0970b532a589 (diff)
downloadcpython-18bedc08c9a8216c93476e3da1cc4a3922d4cba6.tar.gz
Optimize slots: avoid temporary PyMethodObject
Issue #29507: Optimize slots calling Python methods. For Python methods, get the unbound Python function and prepend arguments with self, rather than calling the descriptor which creates a temporary PyMethodObject. Add a new _PyObject_FastCall_Prepend() function used to call the unbound Python method with self. It avoids the creation of a temporary tuple to pass positional arguments. Avoiding temporary PyMethodObject and avoiding temporary tuple makes Python slots up to 1.46x faster. Microbenchmark on a __getitem__() method implemented in Python: Median +- std dev: 121 ns +- 5 ns -> 82.8 ns +- 1.0 ns: 1.46x faster (-31%) Co-Authored-by: INADA Naoki <songofacandy@gmail.com>
Diffstat (limited to 'Lib/test/test_exceptions.py')
0 files changed, 0 insertions, 0 deletions