Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!news.astraweb.com!border2.a.newsrouter.astraweb.com!news.tele.dk!news.tele.dk!small.news.tele.dk!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'works.': 0.09; 'python': 0.11; 'assume': 0.14; 'ast': 0.16; 'benefit.': 0.16; 'ought': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'language': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'rules': 0.22; 'header:User-Agent:1': 0.23; 'case.': 0.24; 'received:comcast.net': 0.24; 'math': 0.24; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'program,': 0.31; 'clever': 0.31; 'know.': 0.32; 'guess': 0.33; 'something': 0.35; 'there': 0.35; '+0200,': 0.36; 'possible': 0.36; 'expected': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'simply': 0.61; 'real': 0.63; 'such': 0.63; 'provide': 0.64; 'benefit': 0.68 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: (-1)**1000 Date: Sun, 26 Oct 2014 16:45:12 -0400 References: <54476a77$0$21664$426a74cc@news.free.fr> <544d5499$0$41762$c3e8da3$5d8fb80f@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <544d5499$0$41762$c3e8da3$5d8fb80f@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414356325 news.xs4all.nl 2866 [2001:888:2000:d::a6]:56253 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3592 X-Received-Body-CRC: 1679951686 Xref: csiph.com comp.lang.python:79726 On 10/26/14 4:07 PM, Tony the Tiger wrote: > On Wed, 22 Oct 2014 10:27:34 +0200, ast wrote: > >> If i am writing (-1)**1000 on a python program, will the interpreter do >> (-1)*(-1)*...*(-1) or something clever ? > > Even vs. odd. It ought to know. I would assume from a set of defined > rules how math works. There is such a thing as an optimization that isn't worthwhile to perform, simply because it's expected to provide so little benefit. The language implementors have to trade off the cost of adding the optimization to the implementation, against the possible benefit people would get from it. Benefit in this case would have to include a guess as to how often real programs would hit the optimization case. -- Ned Batchelder, http://nedbatchelder.com