python / python/cpython

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

Offen
#139,074 2 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@rhettinger arbeitet bereits daran.

Seit 17.9.2025.

extension-modules type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.