Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'programmer': 0.03; 'represents': 0.05; 'subject:number': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'missed': 0.12; 'language.': 0.14; '(regardless': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer.': 0.16; 'reedy': 0.16; 'stark': 0.16; 'subject:skip:m 10': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'fit': 0.20; 'machine': 0.22; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'sorry,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'dramatic': 0.31; 'subject:all': 0.32; 'implemented': 0.33; 'actual': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'edge': 0.36; 'two': 0.37; 'performance': 0.37; 'loss': 0.38; 'machines': 0.38; '12,': 0.39; 'sure': 0.39; 'increased': 0.61; 'numbers': 0.61; 'course': 0.61; 'more': 0.64; 'effectively': 0.66; 'between': 0.67; 'believe': 0.68; 'products': 0.71; '2015': 0.84; 'comparable': 0.84; 'subject:find': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=0/Bqn4PsmdidjYGMFddfxjZJCxOiVRdWTaX9uiTUYyA=; b=WySTrif65jxsRMK0j1JvQID84bHoqlyvL29R8WpqcxNHZ0VzxY8cuVEezwDdIXcKIX ea7zGtVi62pf7DKIu1XkZ6QZwcW9CcLaknsh6fZXkGNA1YacxGixqXikGudfCW0Y0ZsU jhBau+mVXp4SKe0Q1codzKcSZHV6BIVTKZ0AaCW9QjTidPv3QeHJHxuhzKtw6T/sMRa0 5GVm291qBmXNjhiRk7hHavWuOQtJB/ADymeuQUU1578BguL4A+ILBbdW5FhwcfnhoGm6 G9mXCRsCfUTrBXr+kA0uoyHc4CnwTmH4cxabUfPAoNdX5ppUSqfgOtMAay5DnSW3rJSA mPfw== MIME-Version: 1.0 X-Received: by 10.43.39.1 with SMTP id tk1mr11369183icb.26.1428797791746; Sat, 11 Apr 2015 17:16:31 -0700 (PDT) In-Reply-To: References: <890bd388-f50a-4dec-9ef5-27715427472a@googlegroups.com> <55288135$0$12997$c3e8da3$5496439d@news.astraweb.com> <87egnrb3il.fsf@jester.gateway.sonic.net> <87619387c0.fsf@elektro.pacujo.net> <87y4lya9eo.fsf@jester.gateway.sonic.net> <87zj6e7erv.fsf@elektro.pacujo.net> <87pp7aa6x0.fsf@jester.gateway.sonic.net> Date: Sun, 12 Apr 2015 10:16:31 +1000 Subject: Re: find all multiplicands and multipliers for a number From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428797794 news.xs4all.nl 2856 [2001:888:2000:d::a6]:57812 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88850 On Sun, Apr 12, 2015 at 9:58 AM, Terry Reedy wrote: > I believe longobject effectively represents ints in base 2**15 or 2**30 (or > 31?) for 32 and 64 bit machines, so that products of 'digits' fit in a > single machine word. (I am not sure if the increased size for 64 bit > machines was implemented or not.) > >> Performance doesn't seem to change in Py3 as >> the numbers get bigger: > > I suspect the effect is more dramatic with multiplication. Sorry, sloppy language. Of course larger numbers will be a bit slower, but there's no stark change at the edge of the machine word. The performance loss from going from one limb to two will be comparable to the loss from going from five to six, where it's already well past machine integer. In Py2, there's a significant difference between "int" performance and "long" performance (regardless of the actual size of integer involved), but Py3 is more consistent. It's a missed optimization at worst, but the upshot is that a Python programmer doesn't need to think about integer sizes at all. ChrisA