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


Groups > comp.lang.python > #89595

Re: Lucky numbers in Python

Path csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!81.171.88.16.MISMATCH!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.099
X-Spam-Evidence '*H*': 0.81; '*S*': 0.01; 'subject:Python': 0.06; '(best': 0.09; 'cest': 0.09; 'omit': 0.09; 'item)': 0.16; 'seconds.': 0.16; 'slice,': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'certainly': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; '(which': 0.31; 'concise': 0.31; 'long.': 0.31; 'subject:numbers': 0.31; 'probably': 0.32; 'received:google.com': 0.35; 'seconds': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'delete': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'ian': 0.60; 'middle': 0.60; 'times': 0.62; 'term': 0.63; 'more': 0.64; '2015': 0.84; 'clearer': 0.84; 'faster.': 0.84; 'hundred': 0.95
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=uGIQYgGAYIFl2sWKs9+YAUcfH9ndfGCCj3BfUz3ZVn4=; b=xZQ3JPgtHcV9liexopIOIVxmssG1Ouz91v0ATUI2Pchm0EZbkUwIA1CWRf6KTKgCue H8U0RkB/OA0uGoEfMT2WDnmuBQ74peE4aAwz9Zw0UT1QjFWXlXAhQiAwYTSy/02zJkkA AWXBdCUFN0i5oN2mQU4H3Uj1zX/A6iFqgpwWu6pPE3jwsHHl7DFg6Zcdh0o/iUhloN0e hgjDzfyTgfTkhrqAilu8WCqTXS5nvuPXflsl6dllZ8SAcRC3EToWDyO7owfz5Aimw2q+ aIOSTK5BlCaLnTxJzZdzmaS9M2YGLNQaQk3pB998zltYsTGKlOvgl699pRCCycILLcip buRQ==
X-Received by 10.107.12.158 with SMTP id 30mr2652325iom.61.1430362570381; Wed, 29 Apr 2015 19:56:10 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <871tj2bi2p.fsf@Equus.decebal.nl>
References <87lhhabxod.fsf@Equus.decebal.nl> <mailman.95.1430337506.3680.python-list@python.org> <87d22mbod7.fsf@Equus.decebal.nl> <mailman.103.1430347166.3680.python-list@python.org> <871tj2bi2p.fsf@Equus.decebal.nl>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 29 Apr 2015 20:55:29 -0600
Subject Re: Lucky numbers in Python
To Python <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.110.1430362572.3680.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1430362572 news.xs4all.nl 2853 [2001:888:2000:d::a6]:56942
X-Complaints-To abuse@xs4all.nl
X-Received-Body-CRC 1900867754
X-Received-Bytes 4019
Xref csiph.com comp.lang.python:89595

Show key headers only | View raw


On Wed, Apr 29, 2015 at 6:01 PM, Cecil Westerhof <Cecil@decebal.nl> wrote:
> Op Thursday 30 Apr 2015 00:38 CEST schreef Ian Kelly:
>> In that case you can definitely omit the middle term of the slice,
>> which will be both more concise and clearer in intent, though
>> probably not significantly faster.
>
> It is certainly nit faster. It is even significantly slower. With the
> middle term lucky_numbers(int(1e6)) takes 0.13 seconds. Without it
> takes 14.3 seconds. Hundred times as long.

That would be rather surprising, since it's the same operation being
performed, so I did my own timing and came up with 0.25 seconds (best
of 3) with the middle term and 0.22 seconds without.

I suspect that you tested it as "del sieve[skip_count - 1 :
skip_count]" (which would delete only one item) rather than "del
sieve[skip_count - 1 :: skip_count]".

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


Thread

Lucky numbers in Python Cecil Westerhof <Cecil@decebal.nl> - 2015-04-29 20:24 +0200
  Re: Lucky numbers in Python Ian Kelly <ian.g.kelly@gmail.com> - 2015-04-29 13:57 -0600
    Re: Lucky numbers in Python Cecil Westerhof <Cecil@decebal.nl> - 2015-04-29 23:45 +0200
      Re: Lucky numbers in Python Ian Kelly <ian.g.kelly@gmail.com> - 2015-04-29 16:38 -0600
        Re: Lucky numbers in Python Cecil Westerhof <Cecil@decebal.nl> - 2015-04-30 02:01 +0200
          Re: Lucky numbers in Python Ian Kelly <ian.g.kelly@gmail.com> - 2015-04-29 20:55 -0600
            Re: Lucky numbers in Python Cecil Westerhof <Cecil@decebal.nl> - 2015-04-30 08:34 +0200
      Re: Lucky numbers in Python Chris Kaynor <ckaynor@zindagigames.com> - 2015-04-29 15:56 -0700
    Re: Lucky numbers in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-04-30 10:11 +1000
      Re: Lucky numbers in Python Ian Kelly <ian.g.kelly@gmail.com> - 2015-04-29 21:08 -0600
  Re: Lucky numbers in Python Cecil Westerhof <Cecil@decebal.nl> - 2015-04-30 20:55 +0200
    Re: Lucky numbers in Python Dave Angel <davea@davea.name> - 2015-04-30 15:28 -0400

csiph-web