Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-125916: convert reduce() to Argument Clinic #125999

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

skirpichev
Copy link
Member

@skirpichev skirpichev commented Oct 26, 2024

@skirpichev
Copy link
Member Author

This coming from #125917. Red alert: to make AC happy, docstring was adjusted.

I did some benchmarks.

# a.py
import pyperf
from functools import reduce

f = lambda x, y: x + y
lst = list(range(5))
init = 123

runner = pyperf.Runner()
runner.bench_func('reduce(f, lst)', reduce, f, lst)
runner.bench_func('reduce(f, lst, init)', reduce, f, lst, init)

Run e.g. with: python a.py -q -o ref.json.

with results:

Benchmark ref patch
reduce(f, lst) 1.27 us 1.19 us: 1.07x faster
reduce(f, lst, init) 1.43 us 1.36 us: 1.05x faster
Geometric mean (ref) 1.06x faster

So, at least AC-backed argument processing offer some speedup.

@erlend-aasland
Copy link
Contributor

Thanks Sergey, I'll review this within today. Ping me tomorrow if I forget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants