Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-102757: fix function signature mismatch forfunctools.reduce between code and documentation#102759
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
XuehaiPan commentedMar 22, 2023
May also need to backport to Python 3.10 and 3.11. This documentation issue is causing real-world problems. Such as: |
arhadthedev commentedMar 22, 2023
@rhettinger (as a functools expert) |
carljm left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks! It makes sense for the CPython
documentation and docstring offunctools.reduce to align with the implementation that is always used in CPython.
XuehaiPan commentedSep 18, 2023
Gentle ping for this. Any updates? |
bedevere-bot commentedSep 18, 2023
|
bedevere-bot commentedSep 18, 2023
|
bedevere-bot commentedSep 18, 2023
|
AA-Turner commentedSep 19, 2023
@carljm should we backport the docs part of this PR? |
carljm commentedSep 20, 2023
@AA-Turner Sure, we can. I don't think it's important, but I guess it's possible it could reduce conflict in some other backport in future. |
…e` between code and documentation (python#102759)
…116398)The `initial` argument in `functools.reduce` can be `None`.```pythoninitial_missing = object()def reduce(function, iterable, initial=initial_missing, /): it = iter(iterable) if initial is initial_missing: value = next(it) else: value = initial for element in it: value = function(value, element) return value```Reference:-python/cpython#102759Pull Requestresolved:#116398Approved by:https://github.com/Skylion007
Summary:The `initial` argument in `functools.reduce` can be `None`.```pythoninitial_missing = object()def reduce(function, iterable, initial=initial_missing, /): it = iter(iterable) if initial is initial_missing: value = next(it) else: value = initial for element in it: value = function(value, element) return value```Reference:-python/cpython#102759X-link:pytorch/pytorch#116398Approved by:https://github.com/Skylion007Reviewed By: izaitsevfb, jeanschmidtDifferential Revision: D52424773fbshipit-source-id: 36d3a6f5f5786350fe8c325773deb135ccbd48e9
Uh oh!
There was an error while loading.Please reload this page.
functools.reducein Python implementation and documentation with the C implementation./to mark all arguments are positional only.functools.reducebetween C implementation, Python implementation, and online documentaion #102757