A lot of code written using functools.reduce is generally hard to understand (if GvR is to be believed!), this is exacerbated by the fact that the initial argument is position-only.
# instead of this
reduce(sub, [1, 1, 2, 3, 5, 8], 21)
# the following version is objectively more clear
reduce(sub, [1, 1, 2, 3, 5, 8], initial=21)
Ideally, it should have been strictly keyword-only argument (just like in itertools.accumulate). But understandably that is not a viable option at this point in time. However, I can’t see any reason to mandate position-only use, nor can I imagine a scenario where having the ability to specify initial via keyword would be detrimental to existing or new code.
In my view, the clarity alone is justification enough, additionally this would be helpful to make a partial function out of reduce with default initial argument.
EDIT: A recent example of such change was in str.replace’s count method, which was position-only before 3.13.
Sounds good. I took a quick look at the code and it might not be trivial to do, since the function doesn’t use Argument Clinic. But it’s definitely doable.
I took look on the comment about AC and it seems to be slightly misleading. Hardly reusing args instead of just another local variable will affect performance significantly.
Edit: indeed, this even look faster with AC on simple benchmarks.
I saw that comment too and was suspicious, but didn’t run any benchmarks. If benchmarks show it’s faster (or at least, not slower) with AC, we should definitely switch.
If your pull request has not received any notice from reviewers (that is, no comment made) after one month, first “ping” the issue on the issue tracker to remind the subscribers that the pull request needs a review. If you don’t get a response within a week after pinging the issue, you can post on the Core Development Discourse category to ask for someone to review your pull request.