Content-Length: 302520 | pFad | http://github.com/python/cpython/pull/137130

62 Remove ambiguous part in docstring of functools.reduce() by rabelux · Pull Request #137130 · python/cpython · GitHub
Skip to content

Remove ambiguous part in docstring of functools.reduce() #137130

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

Closed
wants to merge 1 commit into from

Conversation

rabelux
Copy link

@rabelux rabelux commented Jul 26, 2025

To me the description of functools.reduce() sounded like initial will only be used if iterable is empty. This is not the case. Plus I included one additional sentence that was present in https://docs.python.org/3/library/functools.html#functools.reduce but not the docstring.
If this PR gets approved I suggest to also adapt the html-docs accordingly.

Old description could be read that "initial" will only be used if "iterable" is empty. This is not the case. Plus include additional sentence from docs.python.org
@rabelux rabelux requested a review from rhettinger as a code owner July 26, 2025 21:40
@python-cla-bot
Copy link

python-cla-bot bot commented Jul 26, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jul 26, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@picnixz
Copy link
Member

picnixz commented Jul 26, 2025

This would also require to change the C extension module:

_functools.reduce
. The pure Python implementation is just a fallback in case the C implementation is not available. Also, I think it's better for the docstring to be concise, though there is an example inside the docstring so maybe we can be a bit more verbose.

cc @rhettinger

@rabelux
Copy link
Author

rabelux commented Jul 26, 2025

Please let me know what you'd prefer.
I can either remove the last two sentences and adapt the c-file accoringly, or you're happy with the way it is phrased and I'll update the c-file, or you want a completely different solution and take it from here?
At least I hope you agree that the current wording can be misunderstood.

@picnixz
Copy link
Member

picnixz commented Jul 26, 2025

Personally, I think the wording is fine so I would rather not change anything. I understand the "and serves as a default when the iterable is empty" as "in particular, it serves as a default value when the iterable is empty". IOW, it's not its only role. But the new wording would remove any pre-assumption that the reader may have so it's also fine. What matters is that if we change the docstring, then we need to change the docstring at the C level as well.

I don't have any thing I want personally, and I'd rather defer this to Raymond.

@rhettinger
Copy link
Contributor

Personally, I think the wording is fine so I would rather not change anything.

I concur that the current wording is clear enough (and it matches the code equivalent that follows.

@rabelux Thanks for the suggestion, but we will decline.

@rhettinger rhettinger closed this Jul 27, 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.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/pull/137130

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy