Open
Description
Also related to #11913
Currently, math.prod
and math.sumprod
do not properly support Decimal
, Fraction
, complex
, or possibly other numeric types. This makes it inconvenient to replace builtins.sum
with math.prod
in a straightforward manner.
from typing import reveal_type
from fractions import Fraction
from math import prod
a = prod([Fraction(1), Fraction(2)])
reveal_type(a) # it should be Fraction | Literal[1], but float for now
prod([complex(1, 0), complex(1, 2)])
I believe it should be followed the type stub of builtins.sum
, but I’m not sure what breaking changes this might cause.
Activity