[New-bugs-announce] [issue34303] micro-optimizations in functools.reduce()

Sergey Fedoseev report at bugs.python.org
Wed Aug 1 01:09:03 EDT 2018


New submission from Sergey Fedoseev <fedoseev.sergey at 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 <report at bugs.python.org>
<https://bugs.python.org/issue34303>
_______________________________________


More information about the New-bugs-announce mailing list