FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-125916: Adapt functools.reduce() to Argument Clinic by skirpichev · Pull Request #125999 · python/cpython · GitHub

Repository navigation

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

erlend-aasland merged 18 commits into
python:mainfrom
skirpichev:reduce-to-ac

Conversation

skirpichev commented Oct 26, 2024 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

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

I did some benchmarks.

Details
# 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.

Copy link
Copy Markdown
Contributor

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

Comment thread Modules/_functoolsmodule.c Outdated
Comment thread Modules/_functoolsmodule.c Outdated
Comment thread Modules/_functoolsmodule.c Outdated
Comment thread Modules/_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.
skirpichev and others added 2 commits October 28, 2024 07:26
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Comment thread Modules/_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-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>

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Comment thread Modules/_functoolsmodule.c Outdated
skirpichev and others added 2 commits November 1, 2024 18:19
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
erlend-aasland merged commit 51ef54a into python:main Nov 1, 2024

Copy link
Copy Markdown
Contributor

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

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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL