[issue24059] Minor speed and readability improvement to the random module

Tim Peters report at bugs.python.org
Sun Apr 26 00:04:24 CEST 2015


Tim Peters added the comment:

FYI, my results match Serhiy's, on Windows, under Pythons 3.4.2 and 2.7.8.

It's not surprising to me.  Since IEEE 754 standardized sqrt, most vendors complied, delivering a square root "as if infinitely precise" with one anally correct rounding.  But unless the platform pow() special-cases 0.5, that's going to involve a logarithm, multiplication, and exponentiation under the covers.  pow() implementations usually fake some "extra precision" (else the worst-case errors can be horrendous), but it's still not always the same as single-rounding.

Raymond, I didn't understand this part: "It's odd because your two result as same number, just displayed differently."  The output immediately following that showed they _are_ different numbers on your box too (the .hex() outputs differ by one in the last place).

----------

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


More information about the Python-bugs-list mailing list