Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'configure': 0.05; 'nicely': 0.07; 'oh,': 0.09; 'storage.': 0.09; 'python': 0.11; 'stored': 0.12; 'byte,': 0.16; 'internally': 0.16; 'skip:t 100': 0.16; 'subject:search': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '>>>': 0.22; 'memory': 0.22; '(in': 0.22; 'bytes': 0.24; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'array': 0.29; 'message- id:@mail.gmail.com': 0.30; 'comments': 0.31; 'bunch': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'received:google.com': 0.35; 'doing': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'according': 0.40; 'algorithms': 0.60; 'ian': 0.60; 'effectively': 0.66; '2015': 0.84; 'compact,': 0.84; 'subject:find': 0.84; 'subject:Best': 0.91; 'these.': 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:to :content-type; bh=WZCI7XrwO1JQkenT6njAEQ74Dj5PcTirVSHvW71bplA=; b=MWM4IqSfc8oLCdB9LPi1d2jxqPvgJP5Epx0riysrnvJFf+7O7A1m+syj4P+sdeRHTy DJqaRV05s7r3/C2s4whCNf9ES+kEhVaZxHKV7qF9idXNX0yh3IYgvjFPKRa28zpuz9Bl N3cqMs1qiHZAV+FUfo1zBJbb8tNJVc44PmKrrUFX4DB6gZo4exck2fuZN4pdi52WAqze /im8VIIl0KrdfyjQW15LEdZ28gfa/QDegJQ33EX6lECFGrITatyB6PaxxaLCWu1mU/r+ YRdNKkH0kYbcdfXAoEMPjlS3GYLEveetPykUg1M46HsN/DzLZcO13O16xX7fsFnRZRTa 0uOw== X-Received: by 10.42.24.195 with SMTP id x3mr33223808icb.81.1428503881449; Wed, 08 Apr 2015 07:38:01 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <552481d1$0$13005$c3e8da3$5496439d@news.astraweb.com> References: <2e3a3c01-20b3-4948-9b32-bd80ed46822b@googlegroups.com> <9fd13f49-8bfa-43ef-8787-21d5c76a6268@googlegroups.com> <55247896$0$12995$c3e8da3$5496439d@news.astraweb.com> <552481d1$0$13005$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Wed, 8 Apr 2015 08:37:21 -0600 Subject: Re: Best search algorithm to find condition within a range To: Python 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428503889 news.xs4all.nl 2868 [2001:888:2000:d::a6]:54715 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88670 On Tue, Apr 7, 2015 at 7:18 PM, Steven D'Aprano wrote: > On Wed, 8 Apr 2015 10:38 am, Steven D'Aprano wrote: > >> On Wed, 8 Apr 2015 03:44 am, Ian Kelly wrote: >> >>>>>> >> > to_base(2932903594368438384328325832983294832483258958495845849584958458435439543858588435856958650865490, >>>>>> 429496729) >>> [27626525, 286159541, 134919277, 305018215, 329341598, 48181777, >>> 79384857, 112868646, 221068759, 70871527, 416507001, 31] >> >> >> They're not exactly *digits* though, are they? > > Oh, I forgot... I think this is why Python long ints effectively uses a base > 256 internal storage. If memory serves me correctly, internally a long int > is stored as an array of bytes using digits: > > \x0 \x1 \x2 ... \xFF > > (in decimal, 0 to 255). Each digit takes a single byte, so it's nicely > compact, and Python includes a bunch of fast algorithms for doing > arithmetic on these. According to the comments in longintrepr.h, Python uses either 15- or 30-bit digits, determined at configure time.