Skip to content

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

Merged
erlend-aasland merged 18 commits into
python:mainfrom
skirpichev:reduce-to-ac
Nov 1, 2024
Merged

gh-125916: Adapt functools.reduce() to Argument Clinic#125999
erlend-aasland merged 18 commits into
python:mainfrom
skirpichev:reduce-to-ac

Conversation

@skirpichev

@skirpichevskirpichev commented Oct 26, 2024

Copy link
Copy Markdown
Member

@skirpichev

Copy link
Copy Markdown
MemberAuthor

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

I did some benchmarks.

Details
# a.pyimportpyperffromfunctoolsimportreducef=lambdax, y: x+ylst=list(range(5))
init=123runner=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:

Benchmarkrefpatch
reduce(f, lst)1.27 us1.19 us: 1.07x faster
reduce(f, lst, init)1.43 us1.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
Copy Markdown
Contributor

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

Comment threadModules/_functoolsmodule.c Outdated
Comment threadModules/_functoolsmodule.c Outdated
Comment threadModules/_functoolsmodule.c Outdated
Comment threadModules/_functoolsmodule.c Outdated
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.
skirpichevand others added 2 commits October 28, 2024 07:26
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Comment threadModules/_functoolsmodule.c Outdated
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-aaslanderlend-aasland changed the title gh-125916: convert reduce() to Argument Clinicgh-125916: Adapt functools.reduce() to Argument ClinicOct 29, 2024
skirpichevand others added 2 commits October 29, 2024 13:55
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@erlend-aasland

Copy link
Copy Markdown
Contributor

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

@erlend-aasland

Copy link
Copy Markdown
Contributor

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

Comment threadModules/_functoolsmodule.c Outdated
skirpichevand 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:mainNov 1, 2024
@erlend-aasland

Copy link
Copy Markdown
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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@skirpichev@erlend-aasland@JelleZijlstra@serhiy-storchaka