New submission from Sergey Fedoseev <fedoseev.ser...@gmail.com>:
`PyTuple_SetItem()` can be replaced with macro version and `PyObject_Call()` can be used instead of `PyEval_CallObject()`. Here's benchmark results: $ python -m perf timeit --compare-to ~/tmp/cpython-master-venv/bin/python -s "from functools import reduce; from operator import is_; r = range(50000)" "reduce(is_, r)" /home/sergey/tmp/cpython-master-venv/bin/python: ..................... 1.64 ms +- 0.01 ms /home/sergey/tmp/cpython-venv/bin/python: ..................... 1.40 ms +- 0.00 ms Mean +- std dev: [/home/sergey/tmp/cpython-master-venv/bin/python] 1.64 ms +- 0.01 ms -> [/home/sergey/tmp/cpython-venv/bin/python] 1.40 ms +- 0.00 ms: 1.17x faster (-15%) ---------- components: Extension Modules messages: 322841 nosy: sir-sigurd priority: normal severity: normal status: open title: micro-optimizations in functools.reduce() type: enhancement _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34303> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com