[issue26241] repr() and str() are identical for floats in 3.5

Eryk Sun report at bugs.python.org
Sat Jan 30 04:58:55 EST 2016


Eryk Sun added the comment:

> A test with a 100 million random and selected IEEE 64-bit values 
> returned no differences

The float type's tp_str and tp_repr both call float_repr in Objects/floatobject.c. See the 3.5.1 PyFloat_Type definition [1].

Perhaps you were reading something in reference to Python 2, which has separate float_str and float_repr functions. See the 2.7.11 PyFloat_Type definition [2] and the header file where PyFloat_STR_PRECISION is defined to be 12 digits [3].

[1]: https://hg.python.org/cpython/file/v3.5.1/Objects/floatobject.c#l1839
[2]: https://hg.python.org/cpython/file/v2.7.11/Objects/floatobject.c#l2118
[3]: https://hg.python.org/cpython/file/v2.7.11/Include/floatobject.h#l24

----------
nosy: +eryksun

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


More information about the Python-bugs-list mailing list