Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!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.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'builtin': 0.09; 'iterate': 0.09; 'cc:addr:python-list': 0.11; 'skipped': 0.16; 'subject:generator': 0.16; 'think.': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; 'input': 0.22; 'cc:addr:python.org': 0.22; '(or': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'second': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'start,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'could': 0.34; 'received:google.com': 0.35; 'there': 0.35; 'step': 0.37; 'implement': 0.38; 'negative': 0.60; 'july': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'studying': 0.84; 'mistake': 0.91; '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:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=wc/SpXDUeosyiIXYnu2g8g/SFGzJztpka+RFWPzXx/4=; b=KdydPmRWLFUu31MvEpD3A/xnKKyu/rANac+gFDc568XY8muKZjWtSH+DIZOEXpjurh JW042/8glcihdGwfZab5A+5fkkKp7rIkYzT6HrrZZB+Dp2iFHicOztC1wESJdo8C0w0V 4BESDO1nW5SnIwfTYqkApRt2xZiaAtrlYmSRyh2NN+98Iw98ul0V85gxP9fP5Gm0i/qI 5v9FKZ5P4WhbtQvee6b+WZmBNHyACAUsWVYxBSEIxJBK5HyFIAyxX+KBvXk6DqyVtwaF yHfkriPtNZaXPjYJCl6EF8CI/PdaYfAN/XpHBQwGWcQ715kaSscojmDUR31vf0XPFqmU Z44Q== X-Received: by 10.220.6.135 with SMTP id 7mr22109354vcz.72.1373560493699; Thu, 11 Jul 2013 09:34:53 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <56736add-f372-4245-9f50-076b3d44bb00@googlegroups.com> References: <4a81b6a6-023e-4d47-9bd0-bbc0516caf6b@googlegroups.com> <56736add-f372-4245-9f50-076b3d44bb00@googlegroups.com> From: Oscar Benjamin Date: Thu, 11 Jul 2013 17:34:33 +0100 Subject: Re: xslice idea | a generator slice To: Russel Walker Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373560496 news.xs4all.nl 15995 [2001:888:2000:d::a6]:46605 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50466 On 11 July 2013 17:21, Russel Walker wrote: > To confess, this is the second time I've made the mistake of trying to im= plement generator like functionality of a builtin when there already is on = in itertools. Need to start studying that module abit more I think. I'm loo= king at the docs now and I see there are actually a couple of isomethings()= . Your xslice (or mine) would still be better than islice when the step size is large; islice has to iterate over all the skipped elements which could be wasteful if the input is indexable. Also islice doesn't support negative values for start, stop or step which xslice does.