Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; 'elif': 0.04; '3.2': 0.05; 'computed': 0.07; 'linear': 0.07; 'reason.': 0.07; 'python': 0.08; '(line': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:" ': 0.10; 'andreas': 0.16; 'chained': 0.16; 'subject:=': 0.16; 'linux': 0.17; 'header:In-Reply-To:1': 0.22; 'compiled': 0.23; 'statement': 0.25; 'code.': 0.26; 'construct': 0.30; 'there': 0.33; 'to:addr:python-list': 0.33; 'difference': 0.34; 'however,': 0.34; 'header:User-Agent:1': 0.34; 'header:X-Complaints-To:1': 0.35; 'rather': 0.35; 'uses': 0.35; 'switch': 0.35; 'using': 0.37; 'think': 0.38; 'received:org': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'case': 0.39; 'subject: (': 0.39; "it's": 0.40; 'huge': 0.61; 'subject:+': 0.73; 'compiles': 0.84; 'schrieb': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Christian Heimes Subject: Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1") Date: Sun, 21 Aug 2011 20:24:17 +0200 References: <4e513ceb$0$23863$e4fe514c@news2.news.xs4all.nl> <1313947658.3424.3.camel@thegeorge> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: f049204197.adsl.alicedsl.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2.102ipre2 Thunderbird/3.1.11 In-Reply-To: <1313947658.3424.3.camel@thegeorge> X-Enigmail-Version: 1.1.2 OpenPGP: id=AD16AB1B; url=http://cheimes.de/heimes.asc X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313951079 news.xs4all.nl 23881 [2001:888:2000:d::a6]:59901 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11952 Am 21.08.2011 19:27, schrieb Andreas Löscher: > As for using Integers, the first case (line 1319 and 1535) are true and > there is no difference in Code. However, Python uses a huge switch-case > construct to execute it's opcodes and INPLACE_ADD cames after > BINARY_ADD, hence the difference in speed. I don't think that's the reason. Modern compiles turn a switch statement into a jump or branch table rather than a linear search like chained elif statements. Python 3.2 on Linux should also be compiled with computed gotos. Christian