- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
Closed as not planned
Closed as not planned
Copy link
Labels
type-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
math.sumprod should support a start parameter.
# old
def sumprod(p, q, /)
# proposal
def sumprod(p, q, /, *, start=0)Reason:
from __future__ import annotations
from typing import Any
from math import sumprod
class Foo:
    def __add__(self, other: Any) -> Foo:
        return Foo()
    def __mul__(self, other: Any) -> Foo:
        return Foo()
sumprod([Foo()], [Foo()])
# TypeError: unsupported operand type(s) for +: 'int' and 'Foo'For now, math.sumprod starts its calculation from 0 by default, and there seems to be no way to customize this value.
I understand that alternatives like itertools.starmap or defining def __radd__(self, o) exist. But I believe sumprod should support a start parameter for consistency with sum and math.prod.
Metadata
Metadata
Assignees
Labels
type-featureA feature request or enhancementA feature request or enhancement