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


Groups > comp.lang.python > #10843

Re: range() vs xrange() Python2|3 issues for performance

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.027
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'range,': 0.09; 'received:209.85.160.174': 0.09; 'received:mail- gy0-f174.google.com': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'squares': 0.16; 'subject:() ': 0.16; 'subject:issues': 0.16; 'intermediate': 0.16; "wouldn't": 0.17; 'aug': 0.19; 'result.': 0.22; 'header:In-Reply-To:1': 0.22; 'incorrect': 0.23; '\xa0if': 0.23; 'thu,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'correct': 0.29; "i've": 0.33; 'to:addr:python-list': 0.34; 'received:209.85.160': 0.34; 'there': 0.34; 'fail': 0.34; 'but': 0.37; 'using': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'steven': 0.38; 'think': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'called': 0.40; 'give': 0.60; 'results': 0.62; 'perfect': 0.63; '10,000': 0.67; 'square': 0.67; 'perfect,': 0.84; 'technically': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=aYhmhdpndFSk5fjQscBqsv/vAx+Rko6I+LkXpISEBKY=; b=hthZkZ//sw1FCwamMzjr+5Ii8tY7YEW6DNkvnGhCvRkeKLcsIH6WY5vKa3J1TwmX6F 63xP77emRt6li0pyaxyvDTm289z6W+U6IxxgiBusWlTCyAy7EJoH6G8RoNVyYGIPJ0BO gYM17QgFgJkJA/C6VL5GNtxqJcC5eA+y9p9pQ=
MIME-Version 1.0
In-Reply-To <4e3a0b9f$0$29968$c3e8da3$5496439d@news.astraweb.com>
References <prNZp.31508$js7.12436@newsfe01.iad> <4e3a0b9f$0$29968$c3e8da3$5496439d@news.astraweb.com>
Date Thu, 4 Aug 2011 07:59:07 +0100
Subject Re: range() vs xrange() Python2|3 issues for performance
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.1878.1312441150.1164.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312441150 news.xs4all.nl 23973 [2001:888:2000:d::a6]:37004
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10843

Show key headers only | View raw


On Thu, Aug 4, 2011 at 4:01 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
>        a, b = divmod(n, i)
>        if b == 0:
>            total += a+i
>

Wouldn't this fail on squares? It happens to give correct results as
far as I've checked; no square up to 10,000 is called perfect, and
there are no perfect squares in that range, but I think it's
technically using an incorrect intermediate result.

ChrisA

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


Thread

range() vs xrange()  Python2|3 issues for performance harrismh777 <harmar@member.fsf.org> - 2011-08-02 02:12 -0500
  Re: range() vs xrange()  Python2|3 issues for performance garabik-news-2005-05@kassiopeia.juls.savba.sk - 2011-08-02 07:51 +0000
  Re: range() vs xrange()  Python2|3 issues for performance Peter Otten <__peter__@web.de> - 2011-08-02 11:05 +0200
  Re: range() vs xrange()  Python2|3 issues for performance Stefan Behnel <stefan_ml@behnel.de> - 2011-08-02 11:20 +0200
  Re: range() vs xrange()  Python2|3 issues for performance Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-08-02 11:26 +0200
  Re: range() vs xrange() Python2|3 issues for performance Chris Angelico <rosuav@gmail.com> - 2011-08-02 10:52 +0100
  Re: range() vs xrange() Python2|3 issues for performance Chris Angelico <rosuav@gmail.com> - 2011-08-02 11:19 +0100
  Re: range() vs xrange()  Python2|3 issues for performance Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-03 00:45 +1000
    Re: range() vs xrange() Python2|3 issues for performance Chris Angelico <rosuav@gmail.com> - 2011-08-02 17:06 +0100
  Re: range() vs xrange()  Python2|3 issues for performance Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-04 13:01 +1000
    Re: range() vs xrange() Python2|3 issues for performance Chris Angelico <rosuav@gmail.com> - 2011-08-04 07:59 +0100
      Re: range() vs xrange() Python2|3 issues for performance Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-04 19:56 +1000

csiph-web