[Python-ideas] float('∞')=float('inf')
Zaur Shibzukhov
szport at gmail.com
Mon Jul 15 14:05:20 CEST 2013
понедельник, 15 июля 2013 г., 14:26:43 UTC+4 пользователь Oscar Benjamin
написал:
> On 12 July 2013 13:36, Zaur Shibzukhov <szp... at gmail.com <javascript:>>
> wrote:
> >
> > Is it good idea to allow
> > float('∞') to be float('inf') in python?
>
> I don't think so as my preference is for Python to stick to IEEE 754
> as closely as possible.
>
> Section 5.12.1 of IEEE 754-2008 says
> '''
> Conversion of an infinity in a supported format to an external
> character sequence shall produce a language defined one of “inf” or
> “infinity” or a sequence that is equivalent except for case (e.g.,
> “Infinity” or “INF”), with a preceding minus sign if the input is
> negative. Whether the conversion produces a preceding plus sign if the
> input is positive is language-defined.
>
> Conversion of external character sequences “inf” and “infinity”
> (regardless of case) with an optional preceding sign, to a supported
> floating-point format shall produce an infinity (with the same sign as
> the input).
> '''
>
> This does not seem to prohibit accepting other strings for infinity
> but it does explicitly define a set of textual representations for
> infinity. I don't think Python's float <-> str conversions should
> accept (or emit) any other strings for infinity.
>
> Since I was looking at the standard I was also interested to see what
> is says about non-ascii decimal digits (as accepted by Python 3).
> Immediately above this in section 5.12 it says
> '''
> Issues of character codes (ASCII, Unicode, etc.) are not defined by
> this standard.
> '''
>
> My interpretation of that is that Python's current behaviour is
> conforming but that it would also be conforming if it didn't accept
> non-ascii decimal digits.
>
>
> With this we could agree if python completely drop support for non-ascii
input.
As for IEEE-754-2008, it not fully defined presentation of infinity because
we now could have several strings that could identified as "infinity" (inf,
Inf, INF, infinity, Infinity, INFINITY). So if IEEE committee will decide
to designate one single textual view of infinity that could be ok.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130715/45919686/attachment.html>
More information about the Python-ideas
mailing list