Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52953

Re: Fast conversion of numbers to numerator/denominator pairs

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 <timothy.c.delaney@gmail.com>
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&gt;': 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 <CAN8CLgm-DPNKXBWbx-jNX+U4OYktqDya-kpeiOGjMNN0ey8tdg@mail.gmail.com>
References <521828e7$0$29986$c3e8da3$5496439d@news.astraweb.com> <CAN8CLgm-DPNKXBWbx-jNX+U4OYktqDya-kpeiOGjMNN0ey8tdg@mail.gmail.com>
Date Sun, 25 Aug 2013 08:05:50 +1000
Subject Re: Fast conversion of numbers to numerator/denominator pairs
From Tim Delaney <timothy.c.delaney@gmail.com>
To "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>
Content-Type multipart/alternative; boundary=047d7b6700c9dbed9e04e4b8b92b
Cc Python-List <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.203.1377381953.19984.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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.

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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Fast conversion of numbers to numerator/denominator pairs Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-24 03:30 +0000
  Re: Fast conversion of numbers to numerator/denominator pairs Ian Kelly <ian.g.kelly@gmail.com> - 2013-08-24 01:37 -0600
  Re: Fast conversion of numbers to numerator/denominator pairs Ian Kelly <ian.g.kelly@gmail.com> - 2013-08-24 01:50 -0600
  Re: Fast conversion of numbers to numerator/denominator pairs Peter Otten <__peter__@web.de> - 2013-08-24 14:52 +0200
  Re: Fast conversion of numbers to numerator/denominator pairs Tim Delaney <timothy.c.delaney@gmail.com> - 2013-08-25 07:59 +1000
  Re: Fast conversion of numbers to numerator/denominator pairs Tim Delaney <timothy.c.delaney@gmail.com> - 2013-08-25 08:05 +1000

csiph-web