Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #110778

Re: Assignment Versus Equality

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Assignment Versus Equality
Date Wed, 29 Jun 2016 23:34:48 +1000
Lines 40
Message-ID <mailman.107.1467207299.2358.python-list@python.org> (permalink)
References <8a53c069-ca13-47bf-a24e-d2393a018b22@googlegroups.com> <nkobtu$gaq$1@dont-email.me> <l8svmbdf95jh54nmal5h3130cgmhreo3ot@4ax.com> <mailman.4.1466954526.2358.python-list@python.org> <nkotei$dk9$1@dont-email.me> <nkotv4$fif$1@dont-email.me> <nkrbgb$oc5$1@ger.gmane.org> <mailman.32.1467035992.2358.python-list@python.org> <4e72d24b-07b4-484c-83f8-a1fecc727f8c@googlegroups.com> <5773340f$0$1616$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmqyR2POEe8ng6n-3-ih66JF9aXi1iq2Fhu6pxhR-7KV4w@mail.gmail.com> <mailman.96.1467174006.2358.python-list@python.org> <34aa9c69-cdd5-437c-a32b-9a706ef6d9c0@googlegroups.com> <57735c0a$0$2864$c3e8da3$76491128@news.astraweb.com> <311c9890-8588-45f1-85a3-478e18268508@googlegroups.com> <57736ea1$0$2933$c3e8da3$76491128@news.astraweb.com> <CAPTjJmoHtZpx2RCVdGo7A6VYESG-8z-7NCTy5i+ugK1kjbpJZQ@mail.gmail.com> <mailman.100.1467187791.2358.python-list@python.org> <5773c0b5$0$1608$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmpeELKyVw9=fbkru69zdC5+VXJnNUdGws8-ecT3fNhcLg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de LHaDO8WGsFrsv5Gw2illmwtHL+Ifn37P3M0TTjyEibYA==
Return-Path <rosuav@gmail.com>
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; 'run,': 0.07; 'cc:addr :python-list': 0.09; 'x86_64': 0.09; 'python': 0.10; 'wed,': 0.15; "(you're": 0.16; '2016': 0.16; '478': 0.16; 'bigger.': 0.16; 'digits.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'uname': 0.16; 'unfair': 0.16; 'wrote:': 0.16; 'obviously': 0.16; "shouldn't": 0.18; '(in': 0.18; 'tests': 0.18; 'runs': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'performing': 0.23; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; 'linux': 0.26; 'message-id:@mail.gmail.com': 0.27; 'values': 0.28; 'python2.7': 0.29; 'compared': 0.30; "d'aprano": 0.33; 'steven': 0.33; "i'll": 0.33; 'running': 0.34; 'received:google.com': 0.35; 'so,': 0.35; 'mine': 0.35; "isn't": 0.35; 'but': 0.36; 'there': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'skip:4 10': 0.38; 'skip:x 10': 0.40; 'your': 0.60; 'per': 0.62; 'different': 0.63; '10000': 0.66; 'virtually': 0.66; 'bignums': 0.84; 'chrisa': 0.84; 'smp': 0.84; 'too:': 0.84; 'absolutely': 0.88; 'to:none': 0.91; 'same,': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=DIctQv0dwNSvAUd6i81dnujGxqkxPii53M1eFhBQFmQ=; b=XyhvT4vcKnbCD5qoomoGBJ1qSPsLJY88kYT1TOFugytEzEBtxxhMc3v/92z4NINpIm TjzOEHE8E6GNnGVd3XsDpDyFDQICI23E8GjdXViCAy/b7IuP++DWbeQKxnP94YNXe1vl ZGGvHnfoPtdRxc3gNbfAtnmOOpLQt3+5lr+NNK92WqnRl1UdD6M4pOIEiuAI7Ln3erMN Lkhym+U6xvALZbXjM4xwXVkS89UUTkIHzl2xpOKy1QPJj1oYI8RjpsdG9Lac4LKEWJcD zqMt0mPMLm9nCgM+2bLsErRn1SbcMSlC25cQ5A6/UH5xA6NvUuVkSMF1lOuv4BoaFF2u F96A==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=DIctQv0dwNSvAUd6i81dnujGxqkxPii53M1eFhBQFmQ=; b=JwvK9DfHvO0lfCV8tuvUOC+kod4nKn6AeHcSL2KpmUbZl8ajsNgXi9SQmQiiHUWKAV D8z+NL972590VljVNXeojxxvsfYDzczgYfdfNrqk2Y52HFZKz4gwoH4cFjiDDGX1HxJx wRKAtT+B0FuaUz55gy+YiuPBMKLoFn8nTNpbQ+x+WA8YDDB/HW3VIXuVioUorXLNpLS7 igrU3FM57J2mZ2KVFJMY2ggvbhTrBHjr776R0HY5CmWwROp0GZoPouN2TjuIDvQ4LMqq Mjuh5RLyE4oUGQ2vuSqXjQYlN4J1+lun2x1rBk9KjkCWZ0veA1bKJM+IPkfJFC9GdInZ y7Wg==
X-Gm-Message-State ALyK8tKPuUvbTOI1vn/fz77aRaMcIUqKkz5EiaQjv+PHii3dB19QtWl9VwA727j4vxwFA7lmVrJIbJ/6DJX2nQ==
X-Received by 10.28.30.149 with SMTP id e143mr8842257wme.81.1467207290565; Wed, 29 Jun 2016 06:34:50 -0700 (PDT)
In-Reply-To <5773c0b5$0$1608$c3e8da3$5496439d@news.astraweb.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAPTjJmpeELKyVw9=fbkru69zdC5+VXJnNUdGws8-ecT3fNhcLg@mail.gmail.com>
X-Mailman-Original-References <8a53c069-ca13-47bf-a24e-d2393a018b22@googlegroups.com> <nkobtu$gaq$1@dont-email.me> <l8svmbdf95jh54nmal5h3130cgmhreo3ot@4ax.com> <mailman.4.1466954526.2358.python-list@python.org> <nkotei$dk9$1@dont-email.me> <nkotv4$fif$1@dont-email.me> <nkrbgb$oc5$1@ger.gmane.org> <mailman.32.1467035992.2358.python-list@python.org> <4e72d24b-07b4-484c-83f8-a1fecc727f8c@googlegroups.com> <5773340f$0$1616$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmqyR2POEe8ng6n-3-ih66JF9aXi1iq2Fhu6pxhR-7KV4w@mail.gmail.com> <mailman.96.1467174006.2358.python-list@python.org> <34aa9c69-cdd5-437c-a32b-9a706ef6d9c0@googlegroups.com> <57735c0a$0$2864$c3e8da3$76491128@news.astraweb.com> <311c9890-8588-45f1-85a3-478e18268508@googlegroups.com> <57736ea1$0$2933$c3e8da3$76491128@news.astraweb.com> <CAPTjJmoHtZpx2RCVdGo7A6VYESG-8z-7NCTy5i+ugK1kjbpJZQ@mail.gmail.com> <mailman.100.1467187791.2358.python-list@python.org> <5773c0b5$0$1608$c3e8da3$5496439d@news.astraweb.com>
Xref csiph.com comp.lang.python:110778

Show key headers only | View raw


On Wed, Jun 29, 2016 at 10:36 PM, Steven D'Aprano <steve@pearwood.info> wrote:
>> rosuav@sikorsky:~$ python2.7 -m timeit -s "n = 0" "for i in
>> xrange(10000): n += i"
>> 10000 loops, best of 3: 192 usec per loop
>> rosuav@sikorsky:~$ python2.7 -m timeit -s "n = 1<<100" "for i in
>> xrange(10000): n += i"
>> 1000 loops, best of 3: 478 usec per loop
>
> Now *that's* an unfair benchmark, because we know that BigNums get slower as
> they get bigger. A BigNum with 30+ digits is not going to perform like a
> BigNum with 8 digits.

On its own, perhaps. But then I do the exact same tests on Python 3,
and the numbers are virtually identical - suggesting that the bignum
slowdown isn't all that significant at all. But in case you're
worried, I'll do it your way too:

rosuav@sikorsky:~$ python2.7 -m timeit -s "n = 0" "for i in
xrange(10000): n += i"
10000 loops, best of 3: 192 usec per loop
rosuav@sikorsky:~$ python2.7 -m timeit -s "n = 1<<100" "for i in
xrange(10000): n += i"
1000 loops, best of 3: 476 usec per loop
rosuav@sikorsky:~$ python2.7 -m timeit -s "n = 0L" "for i in
xrange(10000): n += i"
1000 loops, best of 3: 476 usec per loop

So, once again, my system shows that there's a definite slowdown from
using bignums - and it's the same whether I start with 1<<100 or 0L.
(In this particular run, absolutely precisely the same, but other runs
showed numbers like 479 and 486.) What's different about your system
that you see short ints as performing exactly the same as long ints?
Obviously you're running on a slower computer than mine (you're seeing
msec values compared to my usec), but that shouldn't be significant.
Is there a massive architectural difference?

rosuav@sikorsky:~$ uname -a
Linux sikorsky 4.6.0-1-amd64 #1 SMP Debian 4.6.1-1 (2016-06-06) x86_64 GNU/Linux

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-26 00:36 -0700
  Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-26 11:48 +0100
    Re: Assignment Versus Equality Steven D'Aprano <steve@pearwood.info> - 2016-06-26 23:21 +1000
      Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-26 07:26 -0700
        Re: Assignment Versus Equality Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-06-26 11:31 -0400
      Re: Assignment Versus Equality Christopher Reimer <christopher_reimer@icloud.com> - 2016-06-26 11:47 -0700
      Re: Assignment Versus Equality Michael Torrie <torriem@gmail.com> - 2016-06-26 15:28 -0600
      Re: Assignment Versus Equality Bob Gailer <bgailer@gmail.com> - 2016-06-27 08:22 -0400
        Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-27 05:48 -0700
          Re: Assignment Versus Equality Steven D'Aprano <steve@pearwood.info> - 2016-06-27 23:28 +1000
            Re: Assignment Versus Equality Marko Rauhamaa <marko@pacujo.net> - 2016-06-27 16:58 +0300
            Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-27 07:23 -0700
              Re: Assignment Versus Equality Steven D'Aprano <steve@pearwood.info> - 2016-06-28 11:05 +1000
                Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-27 21:31 -0700
                Re: Assignment Versus Equality Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-28 15:42 +1000
                Re: Assignment Versus Equality Chris Angelico <rosuav@gmail.com> - 2016-06-28 16:04 +1000
                Re: Assignment Versus Equality Marko Rauhamaa <marko@pacujo.net> - 2016-06-28 09:12 +0300
                Re: Assignment Versus Equality Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-06-28 11:04 +0300
                Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-27 23:09 -0700
                Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-28 00:12 -0700
                Re: Assignment Versus Equality Chris Angelico <rosuav@gmail.com> - 2016-06-28 17:26 +1000
                Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-28 01:49 -0700
                Re: Assignment Versus Equality Chris Angelico <rosuav@gmail.com> - 2016-06-28 20:34 +1000
                Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-28 17:42 -0700
                Re: Assignment Versus Equality Random832 <random832@fastmail.com> - 2016-06-28 10:13 -0400
                Re: Assignment Versus Equality Marko Rauhamaa <marko@pacujo.net> - 2016-06-28 19:39 +0300
                Re: Assignment Versus Equality Marko Rauhamaa <marko@pacujo.net> - 2016-06-28 19:41 +0300
                Re: Assignment Versus Equality Random832 <random832@fastmail.com> - 2016-06-28 13:19 -0400
                Re: Assignment Versus Equality Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-28 12:27 -0600
                Re: Assignment Versus Equality Marko Rauhamaa <marko@pacujo.net> - 2016-06-28 22:40 +0300
                Re: Assignment Versus Equality Gene Heskett <gheskett@shentel.net> - 2016-06-28 16:59 -0400
                Re: Assignment Versus Equality Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-30 12:29 +1200
                Re: Assignment Versus Equality Steven D'Aprano <steve@pearwood.info> - 2016-06-30 12:50 +1000
                Re: Assignment Versus Equality Marko Rauhamaa <marko@pacujo.net> - 2016-06-30 09:22 +0300
                Re: Assignment Versus Equality Steven D'Aprano <steve@pearwood.info> - 2016-06-29 12:27 +1000
                Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-28 20:52 -0700
                Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-28 21:03 -0700
                Re: Assignment Versus Equality Random832 <random832@fastmail.com> - 2016-06-29 00:52 -0400
              Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-27 18:14 -0700
            Re: Assignment Versus Equality Gene Heskett <gheskett@shentel.net> - 2016-06-27 11:21 -0400
          Re: Assignment Versus Equality Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-06-27 20:04 -0400
    Re: Assignment Versus Equality Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-06-26 11:21 -0400
      Re: Assignment Versus Equality Cousin Stanley <HooDunnit@didly42KahZidly.net> - 2016-06-26 08:47 -0700
        Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-26 16:56 +0100
          Re: Assignment Versus Equality Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-27 11:38 +1200
          Re: Assignment Versus Equality Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-06-27 07:30 -0400
            Re: Assignment Versus Equality Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-28 18:17 +1200
          Re: Assignment Versus Equality Grant Edwards <grant.b.edwards@gmail.com> - 2016-06-27 13:59 +0000
            Re: Assignment Versus Equality Marko Rauhamaa <marko@pacujo.net> - 2016-06-27 17:09 +0300
              Re: Assignment Versus Equality sohcahtoa82@gmail.com - 2016-06-27 17:33 -0700
                Re: Assignment Versus Equality Marko Rauhamaa <marko@pacujo.net> - 2016-06-28 07:25 +0300
                Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-27 23:54 -0700
            Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-27 07:10 -0700
              Re: Assignment Versus Equality Steven D'Aprano <steve@pearwood.info> - 2016-06-29 12:35 +1000
                Re: Assignment Versus Equality Chris Angelico <rosuav@gmail.com> - 2016-06-29 14:19 +1000
                Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-28 21:51 -0700
                Re: Assignment Versus Equality Chris Angelico <rosuav@gmail.com> - 2016-06-29 15:07 +1000
                Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-28 22:55 -0700
                Re: Assignment Versus Equality Chris Angelico <rosuav@gmail.com> - 2016-06-29 16:26 +1000
                Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-28 23:33 -0700
                Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-28 23:37 -0700
                Re: Assignment Versus Equality Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-29 15:26 +1000
                Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-28 22:51 -0700
                Re: Assignment Versus Equality Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-29 16:45 +1000
                Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-29 01:07 -0700
                Re: Assignment Versus Equality Chris Angelico <rosuav@gmail.com> - 2016-06-29 18:09 +1000
                Re: Assignment Versus Equality Steven D'Aprano <steve@pearwood.info> - 2016-06-29 22:36 +1000
                Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-29 14:24 +0100
                Re: Assignment Versus Equality Chris Angelico <rosuav@gmail.com> - 2016-06-29 23:35 +1000
                Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-29 15:47 +0100
                Re: Assignment Versus Equality Chris Angelico <rosuav@gmail.com> - 2016-06-29 23:34 +1000
                Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-29 10:49 +0100
                Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-29 02:56 -0700
                Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-29 11:10 +0100
                Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-29 03:24 -0700
            Re: Assignment Versus Equality Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2016-06-27 16:48 +0200
              Re: Assignment Versus Equality Rustom Mody <rustompmody@gmail.com> - 2016-06-27 22:00 -0700
            Re: Assignment Versus Equality Steven D'Aprano <steve@pearwood.info> - 2016-06-28 11:34 +1000
          Re: Assignment Versus Equality MRAB <python@mrabarnett.plus.com> - 2016-06-27 16:27 +0100
            Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-27 14:56 -0700
            Re: Assignment Versus Equality Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-27 15:45 -0700
              Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-28 00:08 +0100
                Re: Assignment Versus Equality Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-06-27 20:11 -0400
                Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-28 11:35 +0100
                Re: Assignment Versus Equality Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-28 18:59 +1200
            Re: Assignment Versus Equality Steven D'Aprano <steve@pearwood.info> - 2016-06-28 11:28 +1000
          Re: Assignment Versus Equality Grant Edwards <grant.b.edwards@gmail.com> - 2016-06-27 15:42 +0000
      Re: Assignment Versus Equality Marko Rauhamaa <marko@pacujo.net> - 2016-06-26 19:11 +0300
    Re: Assignment Versus Equality MRAB <python@mrabarnett.plus.com> - 2016-06-26 16:41 +0100
      Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-26 17:08 +0100
    Re: Assignment Versus Equality Christopher Reimer <christopher_reimer@icloud.com> - 2016-06-26 11:53 -0700
      Re: Assignment Versus Equality Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-27 11:41 +1200
    Re: Assignment Versus Equality Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-27 11:22 +1200
      Re: Assignment Versus Equality BartC <bc@freeuk.com> - 2016-06-27 00:39 +0100
        Re: Assignment Versus Equality Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-28 18:15 +1200

csiph-web