Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: MRAB Newsgroups: comp.lang.python Subject: Re: Pyhon 2.x or 3.x, which is faster? Date: Tue, 8 Mar 2016 02:47:06 +0000 Lines: 38 Message-ID: References: <87d1r6iltx.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 82IZtk1UHzXZiVxXGl0BfQ0ct5eDvn2wz9mV3Zpv3Bog== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'length)': 0.09; 'subject:which': 0.09; 'types:': 0.09; 'python': 0.10; 'def': 0.13; 'instead.': 0.15; "'int'": 0.16; "'long'": 0.16; '2.7:': 0.16; '2.7?': 0.16; '2016': 0.16; 'first:': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'originally,': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'renamed': 0.16; 'version?': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'integer': 0.18; '>>>': 0.20; '3.x': 0.22; 'dropped': 0.22; 'pass': 0.22; 'appears': 0.23; 'nearly': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'chris': 0.26; 'compare': 0.27; 'question': 0.27; 'code:': 0.29; 'compared': 0.30; 'seconds': 0.31; 'another': 0.32; "can't": 0.32; 'received:84': 0.32; 'tue,': 0.34; 'could': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'doing': 0.38; 'version': 0.38; 'someone': 0.38; 'why': 0.39; 'does': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'ten': 0.60; 'care': 0.60; 'your': 0.60; 'yes': 0.62; 'course': 0.62; 'more': 0.63; 'here:': 0.63; 'mar': 0.65; 'friendly': 0.74; '3.4': 0.84; '8.4': 0.84; 'cripple': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=bsGxfxui c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=5ANokUeuAAAA:8 a=FfwU-sHjCRs89iNw5jAA:9 a=CdzRpf1N8zg_cTEu:21 a=LrlNtNdumle6ylQr:21 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett@:2500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104316 On 2016-03-08 01:33, BartC wrote: > On 08/03/2016 01:23, Chris Angelico wrote: >> On Tue, Mar 8, 2016 at 12:00 PM, BartC wrote: >>> Yes of course it does. As does 'being slow'. Take another microbenchmark: >>> >>> def whiletest(): >>> | i=0 >>> | while i<=100000000: >>> | | i+=1 >>> >>> whiletest() >>> >>> Python 2.7: 8.4 seconds >>> Python 3.1: 12.5 seconds >>> Python 3.4: 18.0 seconds >>> >>> Even if you don't care about speed, you must admit that there appears to be >>> something peculiar going on here: why would 3.4 take more than twice as long >>> as 2.7? What do they keep doing to 3.x to cripple it on each new version? >> >> How do your benchmarks compare on this code: >> >> pass > > Let me ask you a follow-on question first: how slow does a new Python > version have to be before even you would take notice? > > Compared with 2.7, 3.4 above is spending nearly an extra ten seconds > doing .... what? I can't understand why someone just wouldn't care. > Part of it will be that Python 2 has 2 integer types: 'int' (fixed length) and 'long' (variable length). Originally, 'int' addition could overflow, but it was more friendly to promote the result to 'long' instead. Python 3 dropped 'int' and renamed 'long' to 'int'.