[Python-ideas] Python Numbers as Human Concept Decimal System

Mark Dickinson dickinsm at gmail.com
Mon Mar 10 14:38:49 CET 2014


On Mon, Mar 10, 2014 at 12:12 PM, Oscar Benjamin <oscar.j.benjamin at gmail.com
> wrote:

> On 10 March 2014 10:59, Steven D'Aprano <steve at pearwood.info> wrote:
> > On Mon, Mar 10, 2014 at 10:07:11AM +0000, Oscar Benjamin wrote:
> >> On 9 March 2014 20:39, Guido van Rossum <guido at python.org> wrote:
> >> > On Sun, Mar 9, 2014 at 1:07 PM, Oscar Benjamin <
> oscar.j.benjamin at gmail.com> wrote:
> >> >>
> >> >> The problem though is with things like +3.14d or -3.14d. Python the
> >> >> language treats the + and - signs as not being part of the literal
> but
> >> >> as separate unary operators.
> >
> > Is that still true? Possibly the peephole optimizer has changed the
> > situation?
>
> Yes it does. It also does the same for "complex literals" even though
> the language formally only defines imaginary literals.


... and don't forget the Python 2.x-only hack for negation of integers:

>>> type(-9223372036854775808)

<type 'int'>

>>> type(-(9223372036854775808))

<type 'long'>

which means that it's not true that Python 2.x behaves "as if" there were
no negative literals.  Python 3 is cleaner in this respect.  I guess this
shows that we *could* in theory reintroduce such a hack for negation of
decimal literals, but I agree with everyone else so far that that would be
a bad idea.

-- 
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140310/22c26861/attachment.html>


More information about the Python-ideas mailing list