[Python-ideas] float('∞')=float('inf')

Alexander Belopolsky alexander.belopolsky at gmail.com
Sat Jul 13 21:33:32 CEST 2013


On Sat, Jul 13, 2013 at 1:25 PM, Philipp A. <flying-sheep at web.de> wrote:

> so don’t be silly everyone. the question is if float('∞') should work and
> i say “why the hell not”


Here is why: float(<unicode string>) remained mostly unchanged since
unicode was added in Python 2.0.  There were internal changes such as a
better rounding algorithm and elimination of platform-dependencies when
parsing special values (-0, inf, nan, etc.), but overall the design
remained the same: replace unicode digits with ASCII equivalents and pass
the result to a more or less equivalent of ISO C strtod.

Note that even accepting non-ASCII digits is not free from criticism.
 Python rejected the ISO C's wcstod approach and did not make float()
parsing locale-dependent.  This was a good decision, but resulted in
float() accepting strings with a mix of scripts that don't represent valid
numbers in any system.  We recently agreed that float() and int() should be
changed to reject mixed scripts, but the best way to do that is still being
discussed.

If we decide that 3.4 is the release in which the way float() and int()
parse unicode change, we should do it in a way that will last until Python
4.0 and hopefully beyond.  This is what I've been trying to achieve in
issue 10581 <http://bugs.python.org/issue10581>, but when it comes to
reviewing actual code rather than posting expletives on python-ideas the
pull of volunteers shrinks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130713/ba0da951/attachment.html>


More information about the Python-ideas mailing list