[issue24567] random.choice IndexError due to double-rounding

Tim Peters report at bugs.python.org
Fri Jul 10 16:49:57 CEST 2015


Tim Peters added the comment:

> Anyway, if we modify random.py, the generated
> numbers should be different, no?

Not in a bugfix release.  The `min()` trick changes no results whatsoever on a box that doesn't do double-rounding.

On a box that does do double-rounding, the only difference in results is that the `min()` trick stops a nasty exception in a relative handful of cases (& makes no difference to any case in which that exception isn't raised).

The sequence of results may be different on platforms with double-rounding and without double-rounding, but that's always been true.  The `min()` trick changes nothing about that either, except to prevent unintended exceptions on double-rounding boxes.

Note that switching to use SSE2 instead also changes nothing on boxes that don't do double-rounding.  It would change some results (beyond _just_ stopping bogus exceptions) on boxes that do double-rounding.

----------

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


More information about the Python-bugs-list mailing list