Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.173 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.70; '*S*': 0.05; 'cc:addr:python-list': 0.11; 'proportion': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.18; 'code.': 0.18; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'subject:/': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'message-id:@mail.gmail.com': 0.30; 'subject:numbers': 0.31; 'received:google.com': 0.35; 'add': 0.35; 'complete.': 0.36; 'should': 0.36; 'turn': 0.37; 'august': 0.61; 'such': 0.63; 'breakdown': 0.68; '10%': 0.74; 'gain': 0.79; '35%': 0.84; 'compiling': 0.84; 'subject:Fast': 0.84; '2013': 0.98 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:to :cc:content-type; bh=EOBDQeSXBOhnnnGLqXZK2aXNkwddDtawWcoi88ntW2U=; b=X18a5fFpYfwYxjBR+HbxpwG+uK9a+MlyJ2oW6dexUr+YNmigX1SQslQgpnA7s4bGMP qdo8kXJztPJUH0qolJhZmfmeA/VzLPerJMBMk4EuinCekH67qWDRHY1kbDMCvqT5WsR9 Qy8skHCrCHTuIBQWHhcv6fp0zqys5p0CRbnr1iOWuhL4eS0s0S6bKEKtmv1VFpix5OU9 vIsWOu8egahJYCpjEwQ1SNzRPUegDGZ9+HuPY3BILFTjnMSCQSurKOXNke1wNfjrNGUR 3QzsGckypHCKLxB1w9V0vGz8O+hoG+pwIKEYiJrXcmWkvUqB44EF866qoiked9uMIWGZ GtoA== MIME-Version: 1.0 X-Received: by 10.182.50.200 with SMTP id e8mr6463311obo.35.1377381950154; Sat, 24 Aug 2013 15:05:50 -0700 (PDT) In-Reply-To: References: <521828e7$0$29986$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 25 Aug 2013 08:05:50 +1000 Subject: Re: Fast conversion of numbers to numerator/denominator pairs From: Tim Delaney To: "Steven D'Aprano" Content-Type: multipart/alternative; boundary=047d7b6700c9dbed9e04e4b8b92b Cc: Python-List 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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377381953 news.xs4all.nl 15880 [2001:888:2000:d::a6]:40148 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52953 --047d7b6700c9dbed9e04e4b8b92b Content-Type: text/plain; charset=UTF-8 On 25 August 2013 07:59, Tim Delaney wrote: > Breakdown of the above (for 19 digits): > > d.as_tuple() takes about 35% of the time. > > The multiply and add takes about 55% of the time. > > The exponentiation takes about 10% of the time. > Bah - sent before complete. Since the multiply and add takes such a significant proportion of the time, compiling the above with Cython should gain you a big win as well. Or find some other way to turn that loop into native code. Tim Delaney --047d7b6700c9dbed9e04e4b8b92b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 25 August 2013 07:59, Tim Delaney <= ;timothy.c= .delaney@gmail.com> wrote:
Breakdown of the above (for 19 digits):

d.as_tuple() takes about 35% of the time.

The multiply and add takes about 55% of the time.

The exponentiation takes about 10% of the time.

Bah - sent before complete.=C2=A0

Since the multiply and add takes such a significant = proportion of the time, compiling the above with Cython should gain you a b= ig win as well. Or find some other way to turn that loop into native code.<= /div>

Tim Delaney
--047d7b6700c9dbed9e04e4b8b92b--