[issue25177] OverflowError in statistics.mean when summing large floats

Bar Harel report at bugs.python.org
Sat Sep 19 15:23:21 CEST 2015


Bar Harel added the comment:

I believe it's an intended behavior as python's float has a limit after all. It's hard to reach it but definitely possible.
A workaround is to internally use Decimal (also take the advantage that it's implementation is now way faster) but it will cause a precision loss, and somewhat unexpected behavior.
Last thing we can do is catch that OverflowError and raise StatisticsError from exc.
I believe catching and re-raising as Statistics or just writing that it may also cause an Overflow error are the most viable ways.
Either way, I'd like another opinion before implementing either method as a patch.

----------
nosy: +bar.harel

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25177>
_______________________________________


More information about the Python-bugs-list mailing list