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: 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> <87d22mbod7.fsf@Equus.decebal.nl> <871tj2bi2p.fsf@Equus.decebal.nl> From: Ian Kelly Date: Wed, 29 Apr 2015 20:55:29 -0600 Subject: Re: Lucky numbers in Python To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Wed, Apr 29, 2015 at 6:01 PM, Cecil Westerhof 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]".