Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'cpython': 0.05; 'operand': 0.07; 'stack.': 0.07; 'atom': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'jan': 0.11; 'interpreter': 0.15; '42,': 0.16; 'evaluates': 0.16; 'evaluating': 0.16; 'operands': 0.16; 'operation,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.16; 'integer': 0.18; 'load': 0.20; '2015': 0.20; 'machine': 0.21; 'next,': 0.22; 'object.': 0.22; 'referring': 0.22; 'am,': 0.23; 'performing': 0.23; "python's": 0.23; 'second': 0.24; 'implemented': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'chris': 0.26; 'points': 0.27; 'right.': 0.27; 'object,': 0.27; 'yields': 0.29; "i'm": 0.30; 'getting': 0.33; 'list': 0.34; 'so,': 0.35; 'execution': 0.35; 'but': 0.36; 'evaluation': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'virtual': 0.38; 'sure': 0.39; 'whatever': 0.39; 'to:addr:python.org': 0.40; 'address': 0.61; 'here.': 0.62; 'to,': 0.63; 'grab': 0.64; 'evaluate': 0.72; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Evaluation order Date: Fri, 10 Jul 2015 08:27:35 -0400 References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436531282 news.xs4all.nl 2896 [2001:888:2000:d::a6]:40767 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93634 On 7/10/2015 8:04 AM, candide wrote: > Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a =C3=A9crit= : >> I'm not sure what contradiction you're referring to, here. The >> evaluation that you're pointing out says, as Terry showed via the >> disassembly, that Python's first action is to look up the name 't' and= >> grab a reference to whatever object it points to. > > But in order to perform an operation, the interpreter has to evaluate > the operands and "evaluating" is not "grabbing a reference to". In the CPython, evaluating a name is implemented as getting the=20 reference corresponding to the name. >> The execution of >> t.sort() has to happen before the multiplication, because of the >> parentheses. > Official docs explains what evaluation is : > > When the name is bound to an object, evaluation of the atom yields that= object. Conceptually, that is exactly right. How that is implemented on a=20 computer in CPython is to load the address on the top of the virtual=20 machine stack. > So, since the Python interpreter is performing evaluation from left to = right, > the first operand of the expression : > > t*(1+int(bool(t.sort()))) > > evaluates to [2020, 42, 2015]. 't' evaluates to the ***mutable*** list that 't' is bound to. > Next, the second operatand evaluates to the integer 1. And in the process of that evaluation, the list is sorted. --=20 Terry Jan Reedy