Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42430

Re: Why does 1**2**3**4**5 raise a MemoryError?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'assignment': 0.07; 'expressions': 0.07; 'expectation': 0.09; 'integers': 0.09; 'paragraph,': 0.09; 'subject:Why': 0.09; 'python': 0.11; '"python': 0.16; 'assignments,': 0.16; 'discusses': 0.16; 'evaluates': 0.16; 'evaluating': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mathematics.': 0.16; 'operands': 0.16; 'operators.': 0.16; 'order)': 0.16; 'picks': 0.16; 'really?': 0.16; 'rhs': 0.16; 'unary': 0.16; 'url:html)': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'alex': 0.19; 'examples': 0.20; 'starts': 0.20; '(the': 0.22; 'mon,': 0.24; 'first,': 0.26; 'right.': 0.26; 'header:In- Reply-To:1': 0.27; 'point': 0.28; 'specifically': 0.29; 'chris': 0.29; 'am,': 0.29; 'evaluation': 0.30; 'message- id:@mail.gmail.com': 0.30; 'calculated': 0.31; 'follows': 0.31; 'themselves': 0.32; 'says': 0.33; 'url:python': 0.33; 'received:209.85': 0.35; 'except': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'in.': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'expression': 0.60; 'url:3': 0.61; 'obvious': 0.74; 'power': 0.76; 'url:reference': 0.84; '6.4': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=pT3N6ayG084TjctmX0adXPTG+6l5FzKNWii8jz78/lc=; b=ZMwtnjxAeDkSZbhhhmfWfSRgC3XAKKrOjXMgmZ+NIKl55KF6YrIiHteqpTj1k3PimD ZM/Hg/ZOC3nHQ+BJbUSJaF1Kfo/5LAQaDnQ5k8WQzI9MM+2jIExAwlBGa/5+B6RYPE/X NObHCAAoiMY7v/sTwmyFyP+3pvG1Kuct/elYOWCjL4Lcz/HkLIvih5ioxBfZCfAwESm1 c45kaL+1G9yN4iF0EGpcWZU3w8rt5LtgpA/deZn86EAUgs/YzykOEQ2VoxtaJA/nnlQq SYIIkUpa4MYFbidhlFbJcHxNuPevX7vf4dd696Lt0F/k7/824oS440R8YkT5HMtjALb0 rIFA==
MIME-Version 1.0
X-Received by 10.52.88.197 with SMTP id bi5mr6446237vdb.58.1364769124230; Sun, 31 Mar 2013 15:32:04 -0700 (PDT)
In-Reply-To <CAPTjJmomE2bsiyJKrb4Kb=TUj4g6KMqZ3GxQ0_p8MSN+RshEhA@mail.gmail.com>
References <8e43bc87-e822-4bb3-b9ef-ccd489da8bf3@googlegroups.com> <mailman.4010.1364715292.2939.python-list@python.org> <kjac1p$qci$1@dont-email.me> <CAPTjJmomE2bsiyJKrb4Kb=TUj4g6KMqZ3GxQ0_p8MSN+RshEhA@mail.gmail.com>
Date Mon, 1 Apr 2013 09:32:04 +1100
Subject Re: Why does 1**2**3**4**5 raise a MemoryError?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4039.1364769131.2939.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364769131 news.xs4all.nl 6859 [2001:888:2000:d::a6]:37543
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42430

Show key headers only | View raw


On Mon, Apr 1, 2013 at 9:28 AM, Chris Angelico <rosuav@gmail.com> wrote:
> On Mon, Apr 1, 2013 at 9:06 AM, Alex <foo@email.invalid> wrote:
>> Really?
>>
>> The Python 3 documentation
>> (http://docs.python.org/3/reference/expressions.html) says in section
>> 6.14 (Evaluation order) that "Python evaluates expressions from left to
>> right" (an exception being when evaluating assignments, in which case
>> the RHS of the assignment is calculated first, in left-to-right order).
>>
>> Section 6.4 discusses the power operator specifically and does not
>> contradict 6.14 except that the power operator uses right-to-left
>> evaluation in the presence of unparenthesized unary operators.
>
> http://docs.python.org/3/reference/expressions.html#operator-precedence
>
> Opening paragraph, "... exponentiation, which groups from right to
> left". It follows the obvious expectation from mathematics. (The OP is
> using Python 2, but the same applies.)

Though your point about 6.14 is still true. It states the order that
the integers will be evaluated in. Note one of the examples given:

expr1 + expr2 * (expr3 - expr4)

The evaluation of the expression starts with 3 and 4, then picks up 2,
then 1, but the operands themselves are evaluated left to right.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why does 1**2**3**4**5 raise a MemoryError? morphex <morphex@gmail.com> - 2013-03-30 23:56 -0700
  Re: Why does 1**2**3**4**5 raise a MemoryError? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-31 07:33 +0000
    Re: Why does 1**2**3**4**5 raise a MemoryError? Dave Angel <davea@davea.name> - 2013-03-31 03:48 -0400
    Re: Why does 1**2**3**4**5 raise a MemoryError? morphex <morphex@gmail.com> - 2013-03-31 05:07 -0700
      Re: Why does 1**2**3**4**5 raise a MemoryError? Dave Angel <d@davea.name> - 2013-03-31 08:43 -0400
        Re: Why does 1**2**3**4**5 raise a MemoryError? Roy Smith <roy@panix.com> - 2013-03-31 09:15 -0400
          Re: Why does 1**2**3**4**5 raise a MemoryError? Jason Swails <jason.swails@gmail.com> - 2013-03-31 10:03 -0400
      Re: Why does 1**2**3**4**5 raise a MemoryError? Roy Smith <roy@panix.com> - 2013-03-31 09:04 -0400
      Re: Why does 1**2**3**4**5 raise a MemoryError? Tim Roberts <timr@probo.com> - 2013-04-01 21:45 -0700
        Re: Why does 1**2**3**4**5 raise a MemoryError? Chris Angelico <rosuav@gmail.com> - 2013-04-02 17:16 +1100
        Re: Why does 1**2**3**4**5 raise a MemoryError? Dan Sommers <dan@tombstonezero.net> - 2013-04-02 12:56 +0000
    Re: Why does 1**2**3**4**5 raise a MemoryError? Roy Smith <roy@panix.com> - 2013-03-31 08:59 -0400
  Re: Why does 1**2**3**4**5 raise a MemoryError? Dave Angel <davea@davea.name> - 2013-03-31 03:34 -0400
    Re: Why does 1**2**3**4**5 raise a MemoryError? "Alex" <foo@email.invalid> - 2013-03-31 22:06 +0000
      Re: Why does 1**2**3**4**5 raise a MemoryError? Chris Angelico <rosuav@gmail.com> - 2013-04-01 09:28 +1100
        Re: Why does 1**2**3**4**5 raise a MemoryError? "Alex" <foo@email.invalid> - 2013-04-01 00:39 +0000
          Re: Why does 1**2**3**4**5 raise a MemoryError? Chris Angelico <rosuav@gmail.com> - 2013-04-01 11:58 +1100
          Re: Why does 1**2**3**4**5 raise a MemoryError? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-01 04:16 +0000
            Re: Why does 1**2**3**4**5 raise a MemoryError? Roy Smith <roy@panix.com> - 2013-04-01 07:48 -0400
          Re: Why does 1**2**3**4**5 raise a MemoryError? Nobody <nobody@nowhere.com> - 2013-04-02 08:40 +0100
      Re: Why does 1**2**3**4**5 raise a MemoryError? Chris Angelico <rosuav@gmail.com> - 2013-04-01 09:32 +1100
      Re: Why does 1**2**3**4**5 raise a MemoryError? Dave Angel <davea@davea.name> - 2013-03-31 18:34 -0400

csiph-web