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

Raymond Hettinger report at bugs.python.org
Sun Jun 24 21:26:06 EDT 2018


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Attaching a patch for 3.6 and 3.7.  Haven't had a chance to run timings yet.  Since it involves adding code to the inner loop, presumably it will have a noticeable affect on speed.  Am not sure how to test this (I don't seem to be able to reproduce the OP's problem on any system I have access to).  I'm not even sure whether the double rounding still exists any extant platform and if so whether we could just turn it off as part of the configuration.

At any rate, I don't think the code in 2.7 should change at all.  That tool is almost at end-of-life and we should be very conservative with it at this point.

----------
Added file: https://bugs.python.org/file47650/random_double_round.diff

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


More information about the Python-bugs-list mailing list