Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; 'python3': 0.07; 'differing': 0.09; 'integers': 0.09; 'optimizing': 0.09; 'system?': 0.09; 'python': 0.11; 'jan': 0.12; 'assume': 0.14; '2.6.4': 0.16; '2.7.3': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'sake,': 0.16; 'somewhere.': 0.16; 'underlying': 0.16; "where's": 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'server,': 0.19; 'feb': 0.22; 'tests': 0.22; 'integer': 0.24; 'versions': 0.24; "i've": 0.25; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'installed': 0.27; 'chris': 0.29; 'am,': 0.29; '???': 0.30; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; '2009,': 0.31; '3.x': 0.31; 'run': 0.32; 'running': 0.33; 'core': 0.34; 'could': 0.34; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'ubuntu': 0.36; 'seconds': 0.37; 'skip:4 10': 0.37; 'two': 0.37; 'received:209': 0.37; 'architecture': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'times': 0.62; 'skip:6 10': 0.63; 'our': 0.64; 'here': 0.66; 'mar': 0.68; 'results': 0.69; 'repeat': 0.74; 'apt-get': 0.84; 'shade': 0.84; 'subject:long': 0.84; '2013,': 0.91; 'differences': 0.93; '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=PtA+hbw9xYD7t3/ZnMj7sCB5QHAL/4iQwPJ/M6ygraE=; b=bs+CMk700xjz7yAKmXn1nPD1zaJHccNqvknKHN6C9okpns7rTlQ5k483zbwam6TTcS IFZuVtA6emRjY0957ZH4ji8TXfXZsxNx4Z6cRv2xSOyt2mW6VPeh4tPxjhC7qIdUGKzy bRT+S5fyDAQi2Ta+ZncrSkQRAeoqv2LT8/lo4G8xve/yQPtDNfsP4pNRJJhIcg8yd+Rj uklqM9QHm45qSTs0YpgLpvzJF5u5/VbaPZCWL/tAY+qVipnL/RUC6UC0lWYvYvl3COay UKYBh7GsVHo7+h/oFASZ6aqkwoedRp1yGw/2R5U2TMgoWILYDGxE9X+C/bUWASLRtBVB yyeQ== MIME-Version: 1.0 X-Received: by 10.220.103.7 with SMTP id i7mr19339907vco.7.1364306897589; Tue, 26 Mar 2013 07:08:17 -0700 (PDT) In-Reply-To: References: Date: Wed, 27 Mar 2013 01:08:17 +1100 Subject: Re: Performance of int/long in Python 3 From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 72 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364306899 news.xs4all.nl 6938 [2001:888:2000:d::a6]:37827 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41902 On Wed, Mar 27, 2013 at 12:38 AM, Cousin Stanley wrote: > Chris Angelico wrote: > >> Interesting, so your 3.x sum() is optimizing something somewhere. >> Strange. Are we both running the same Python ? >> >> I got those from apt-get >> .... > > I also installed python here under Debian Wheezy > via apt-get and our versions look to be the same .... > > -sk- > > 2.7.3 (default, Jan 2 2013, 16:53:07) [GCC 4.7.2] > > 3.2.3 (default, Feb 20 2013, 17:02:41) [GCC 4.7.2] > > CPU : Intel(R) Celeron(R) D CPU 3.33GHz > > > -ca- > > 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2] > > 3.2.3 (default, Feb 20 2013, 14:44:27) [GCC 4.7.2] > > CPU : ??? > > > Could differences in underlying CPU architecture > lead to our differing python integer results ? Doubtful. I have Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz quad-core with hyperthreading, but I'm only using one core for this job. I've run the tests several times and each time, Py2 is a shade under two seconds for inline/range_sum, and Py3 is about 2.5 seconds for each. Fascinating. Just for curiosity's sake, I spun up the tests on my reiplophobic server, still running Ubuntu Karmic. Pentium(R) Dual-Core CPU E6500 @ 2.93GHz. gideon@gideon:~$ python inttime.py 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] inline: 2147450880 2.7050409317 range_sum: 2147450880 2.64918494225 forloop: 2147450880 6.58765792847 forloop_offset: 2147450880L 16.5167789459 gideon@gideon:~$ python3 inttime.py 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22) [GCC 4.4.1] inline: 2147450880 4.44533085823 range_sum: 2147450880 4.37314105034 forloop: 2147450880 12.4834370613 forloop_offset: 2147450880 13.5000522137 Once again, Py3 is slower on small integers than Py2. So where's the difference with your system? This is really weird! I assume you can repeat the tests and get the same result every time? ChrisA