On Thu, Jan 12, 2017, at 06:20, Paul Moore wrote: > On 12 January 2017 at 10:28, Victor Stinner <[email protected]> > wrote: > > George requested this feature on the bug tracker: > > http://bugs.python.org/issue29223 > > > > George was asked to start a discusson on this list. I posted the > > following comment before closing the issue: > > > > You are not the first one to propose the idea. > > OK, but without additional detail (for example, how would the proposed > flag work, if the main module imports module A, then would float > literals in A be decimal or binary? Both could be what the user wants) > it's hard to comment. And as you say, most of this has been discussed > before, so I'd like to see references back to the previous discussions > in any proposal, with explanations of how the new proposal addresses > the objections raised previously.
Having them be decimal is impossible and it therefore hadn't even occurred to me it might be what the user wanted. Though what might be interesting would be to have a mode or variant of the language where *the float type* is, say, decimal128. The documentation carefully avoids guaranteeing any specific representation, or even that it is binary, and the existence of float_info.radix suggests that it may not always be the case. Implementing such a thing would be difficult, of course, and making it switchable at runtime would be even harder. Though since PyFloat_FromDouble/PyFloat_AsDouble would still necessarily be part of the API, it would simply be a case of "modules that are unaware that float may use C double for its internal representation may silently lose precision" Question: Is Py_AS_DOUBLE, which directly accesses a struct field, part of the stable ABI? If so, it may be necessary for every float object to continue carrying around a C double as an 'alternate representation'. Defining it unconditionally to have both representations would also make it somewhat easier to make the behavior a runtime switch, since it would simply change which value is considered authoritative, though it would make everything unconditionally slower as every time a float is constructed the alternate representation must be calculated. _______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
