Skip to content

gh-125916: Adapt functools.reduce() to Argument Clinic #125999

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

Merged
merged 18 commits into from
Nov 1, 2024

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.

PEP 257 says that "Multi-line docstrings consist of a summary line just
like a one-line docstring, followed by a blank line, followed by a more
elaborate description."  This is also a requirement from the Argument
Clinic.
skirpichev and others added 2 commits October 28, 2024 07:26
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
erlend-aasland pushed a commit that referenced this pull request Oct 29, 2024
Yak-shave in preparation for Argument Clinic adaption in gh-125999.
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 29, 2024
Yak-shave in preparation for Argument Clinic adaption in pythongh-125999.
(cherry picked from commit 9b14083)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 29, 2024
Yak-shave in preparation for Argument Clinic adaption in pythongh-125999.
(cherry picked from commit 9b14083)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
erlend-aasland pushed a commit that referenced this pull request Oct 29, 2024
…126113)

Yak-shave in preparation for Argument Clinic adaption in gh-125999.

(cherry picked from commit 9b14083)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
erlend-aasland pushed a commit that referenced this pull request Oct 29, 2024
…126114)

Yak-shave in preparation for Argument Clinic adaption in gh-125999.

(cherry picked from commit 9b14083)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
@erlend-aasland erlend-aasland changed the title gh-125916: convert reduce() to Argument Clinic gh-125916: Adapt functools.reduce() to Argument Clinic Oct 29, 2024
skirpichev and others added 2 commits October 29, 2024 13:55
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@erlend-aasland
Copy link
Contributor

I'll give Jelle and Serhiy a chance to chime in again before landing this.

@erlend-aasland
Copy link
Contributor

I plan to land this later today (post noon ET).

skirpichev and others added 2 commits November 1, 2024 18:19
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@erlend-aasland erlend-aasland merged commit 51ef54a into python:main Nov 1, 2024
37 checks passed
@erlend-aasland
Copy link
Contributor

Thanks for the PR, Sergey; thanks for the reviews, Jelle and Serhiy.

@skirpichev skirpichev deleted the reduce-to-ac branch November 2, 2024 03:10
picnixz pushed a commit to picnixz/cpython that referenced this pull request Dec 8, 2024
Yak-shave in preparation for Argument Clinic adaption in pythongh-125999.
picnixz pushed a commit to picnixz/cpython that referenced this pull request Dec 8, 2024
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
Yak-shave in preparation for Argument Clinic adaption in pythongh-125999.
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
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.

4 participants