Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Assignment Versus Equality Date: Wed, 29 Jun 2016 15:07:03 +1000 Lines: 36 Message-ID: References: <8a53c069-ca13-47bf-a24e-d2393a018b22@googlegroups.com> <4e72d24b-07b4-484c-83f8-a1fecc727f8c@googlegroups.com> <5773340f$0$1616$c3e8da3$5496439d@news.astraweb.com> <34aa9c69-cdd5-437c-a32b-9a706ef6d9c0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de Jaf1NPY0HDIZWahoPedZCgAUM2y3C6mdo6BcJe1FTQVQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python3': 0.05; 'wednesday,': 0.07; 'cc:addr:python-list': 0.09; '(int': 0.09; 'integers': 0.09; 'runtime': 0.09; 'sane': 0.09; 'url:blog': 0.10; 'python': 0.10; 'assume': 0.11; 'wed,': 0.15; '2016': 0.16; 'code?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'py3': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'steep': 0.16; 'tax?': 0.16; 'wrote:': 0.16; 'language': 0.19; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'exists.': 0.22; 'int,': 0.22; 'lawrence': 0.22; 'accuracy': 0.23; 'header:In-Reply-To:1': 0.24; 'linux': 0.26; 'chris': 0.26; 'separate': 0.27; 'message- id:@mail.gmail.com': 0.27; 'boundary': 0.29; 'sure,': 0.29; "i'm": 0.30; 'generally': 0.32; 'instead,': 0.33; 'shift': 0.33; 'gets': 0.35; 'received:google.com': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'data': 0.39; 'does': 0.39; 'making': 0.62; 'course': 0.62; 'more': 0.63; 'real-world': 0.66; 'transparent': 0.66; 'url:10': 0.79; 'bignums,': 0.84; 'chrisa': 0.84; 'huh?': 0.84; 'to:none': 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 :content-transfer-encoding; bh=GC4U+sp8Bm4gRx4R0ZBOO6tjfJpb4zA+2xU2yufqQ0Y=; b=CvxD2FwfiaQdC61jns/nYrt+Oi2MqhMYTKTjF5Nwgoy4JI8NfnZdv6HrlzUOKcP7Dw QvmlhLyOuS6MrKnJz2mgsWJS2RanrYatvHsIbT9k6zPovXAbgOIuWT9tnftARmWL2xxC eJZ5lNI4DqDScqozZUb6OHBurP2ctY+O7XzqbttuiQ1d4LveGaV+00nfLsOc+yp3CJ3m 00HRIPh+lgsRAK6BWjRp5OMVlw8SjrlNY3tsMY+4tYdgGrWnsVNKeXLHXKXSdXSVojaZ y94jom/yYUB2lZ7Yvk0XPTIXk17fdhi82Bqu4oBXVXJamOd+uJkOWLgpb8i120Vfbduf J1GA== 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:content-transfer-encoding; bh=GC4U+sp8Bm4gRx4R0ZBOO6tjfJpb4zA+2xU2yufqQ0Y=; b=jmnUuXIkQ2FjOFZIeWkXOxAs+upXu19mfx7ggzYK7lvFJ9b/6sV/6nZ4HfyygTirhK IgO7piqyMtvtIsGfyUgjgD9fKZsOXjQ5GMQDeby8SgRB+9EWfZM982FF3ccdegsT2qkA BVew5mAz+ERbNZoJnXFFF5KAwibDL0mB4/LsvFwxg4TmglD2jKvlDE9Xv7MAoBx+rl3T mSMgVAmB+HZntpss/J1pzca5UcIlVE8LDxr9H7YbUPR22T55ZyoVgzjWOaN9dAVSAqTQ uop4udK009rrb3CZw4DKfUiApRhQDEjxGhcyhL5iT+/FRGsHKpezmbSmWRyOlcR1PCPL yW9Q== X-Gm-Message-State: ALyK8tIr6WZjW4VGztf/muj7hMW3qL7vHQWFM59xg6oMAPuoG9K5zUki8TUGi30rI8VhBZtJAK516LZS8nQbkA== X-Received: by 10.194.34.202 with SMTP id b10mr6820119wjj.47.1467176824491; Tue, 28 Jun 2016 22:07:04 -0700 (PDT) In-Reply-To: <34aa9c69-cdd5-437c-a32b-9a706ef6d9c0@googlegroups.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <8a53c069-ca13-47bf-a24e-d2393a018b22@googlegroups.com> <4e72d24b-07b4-484c-83f8-a1fecc727f8c@googlegroups.com> <5773340f$0$1616$c3e8da3$5496439d@news.astraweb.com> <34aa9c69-cdd5-437c-a32b-9a706ef6d9c0@googlegroups.com> Xref: csiph.com comp.lang.python:110750 On Wed, Jun 29, 2016 at 2:51 PM, Lawrence D=E2=80=99Oliveiro wrote: > On Wednesday, June 29, 2016 at 4:20:24 PM UTC+12, Chris Angelico wrote: >>> https://www.jwz.org/blog/2010/10/every-day-i-learn-something-new-and-st= upid/ >> >> """It would also be reasonable to assume that any sane language >> runtime would have integers transparently degrade to BIGNUMs, making >> the choice of accuracy over speed, but of course that almost never >> happens...""" >> >> Python 2 did this, but Python 3 doesn't. > > Huh? > > ldo@theon:~> python3 > Python 3.5.1+ (default, Jun 10 2016, 09:03:40) > [GCC 5.4.0 20160603] on linux > Type "help", "copyright", "credits" or "license" for more information= . > >>> 2 ** 64 > 18446744073709551616 > >>> type(2 ** 64) > The transparent shift from machine-word to bignum is what no longer exists. Both Py2 and Py3 will store large integers as bignums; Py2 has two separate data types (int and long), with ints generally outperforming longs, but Py3 simply has one (called int, but functionally like Py2's long), and does everything with bignums. There's no longer a boundary - instead, everything gets the "bignum tax". How steep is that tax? I'm not sure, but microbenchmarking shows that there definitely is one. How bad is it in real-world code? No idea. ChrisA