python / python/cpython

math.sumprod() missing one case for combined int/float inputs.

Open
#139,074 2 comments 0 reactions 1 assignee View on GitHub

@rhettinger is already working on this.

Since Sep 17, 2025.

extension-modules type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

The sumprod function has high precision paths for int/int, int/float, and float/float inputs. However it missed a case when an int/int pair follows another pair that contained a float. In other words, it assumes that once a float is encountered, that subsequent inputs won't contain a pair of ints.

>>> import math
>>> data = [-0.01, 1, -1, 0.01]
>>> math.sumprod(data,  [1, 1, 1, 1])
-8.673617379884035e-18
>>> math.sumprod(data,  [1.0, 1.0, 1.0, 1.0])
0.0
CPython versions tested on:

3.13, 3.15, 3.14

Operating systems tested on:

macOS

Linked PRs
  • gh-139075
  • gh-139085
  • gh-139086
  • gh-139092

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.