Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.038 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'python3': 0.07; '22,': 0.09; '10000000': 0.16; 'check",': 0.16; 'record,': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'looks': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'tim': 0.29; 'message- id:@mail.gmail.com': 0.30; 'usually': 0.31; 'chase': 0.31; 'constant': 0.31; 'context.': 0.31; 'time:': 0.31; 'another': 0.32; 'received:google.com': 0.35; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'otten': 0.84; 'parity': 0.84 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=SLc9lk71D2KL5SWbPP3wRangUq/80ubhmtxtst7fogU=; b=HWh4nfSxS8IAGhAhsbA3sOdqBeDra4V0yX246LADnAeiiSY3V85lZOu3qIBO/8UvCE ZHTEOW5qGq0u25otW91C7d87Jgx/hc13W6gdKn3OlkwAhE2OroSXWAiqPQ8cNmYsPn9B oWRYav3JWntvjTLRIPTKR+Qw7AYNy+shOd97zyDaNP3Nz2mrNfN+lETNa3U5Yp6lDiIe rEG7eJnVZnCmy+pYNg0gwPhvQ2vzH2Qmj1kBxK1icJfIo2DSZPds4Bp9igDdXcx+l9Vb r4unTPI2Iu8oQxibxPNjH+NfPRhBWqx0gkoGnNeCYptjmtmVK0eiLYl5FiaND3fCoPAl 3RJw== X-Received: by 10.68.175.196 with SMTP id cc4mr4142212pbc.147.1413988193684; Wed, 22 Oct 2014 07:29:53 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20141022054302.6daea15b@bigbox.christie.dr> References: <54476a77$0$21664$426a74cc@news.free.fr> <5447786d$0$12750$426a74cc@news.free.fr> <20141022054302.6daea15b@bigbox.christie.dr> From: Ian Kelly Date: Wed, 22 Oct 2014 08:29:13 -0600 Subject: Re: (-1)**1000 To: Python Content-Type: text/plain; charset=UTF-8 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413988202 news.xs4all.nl 2829 [2001:888:2000:d::a6]:40882 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79443 On Wed, Oct 22, 2014 at 4:43 AM, Tim Chase wrote: > On 2014-10-22 12:29, Peter Otten wrote: >> That looks like log(a) while a parity check takes constant time: >> >> $ python3 -m timeit -s 'a = 10**10' 'a & 1' >> 10000000 loops, best of 3: 0.124 usec per loop >> $ python3 -m timeit -s 'a = 10**100' 'a & 1' >> 10000000 loops, best of 3: 0.124 usec per loop >> $ python3 -m timeit -s 'a = 10**1000' 'a & 1' >> 10000000 loops, best of 3: 0.122 usec per loop > > Just for the record, this is a one-bit even/odd check Which is just a verbose way of writing "parity check", even if that phrase is usually used in another context.