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.
fromtypingimportreveal_typefromfractionsimportFractionfrommathimportproda=prod([Fraction(1), Fraction(2)])
reveal_type(a) # it should be Fraction | Literal[1], but float for nowprod([complex(1, 0), complex(1, 2)])
Activity
cake-monotone commented on Feb 14, 2025
useful links
srittau commented on Feb 17, 2025
Any improvements here are welcome!
cake-monotone commented on Feb 17, 2025
Sounds good! I'll work on creating a PR for this issue.