Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.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.048 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'builtin': 0.09; 'iterate': 0.09; 'ah,': 0.16; 'benjamin': 0.16; 'sequence,': 0.16; 'skipped': 0.16; 'subject:generator': 0.16; 'think.': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; 'thu,': 0.19; 'input': 0.22; '(or': 0.24; "i've": 0.25; 'second': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'start,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'could': 0.34; 'point.': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'step': 0.37; 'implement': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'negative': 0.60; 'course': 0.61; 'july': 0.63; 'more': 0.64; 'jul': 0.74; 'oscar': 0.84; '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 :content-type:content-transfer-encoding; bh=eyewNNT0PizMayfB5tpAinxHuw+Ws/uFowySWtPBi38=; b=lnZL5xD7pOoFSVRk4OLsTwnBoxHZ+rC8gbyb2jgyR3AyB0IwDUyejOji5PmiN6MTvb U7AqpmCh/BHH4Y4m6jiddNEw2wLl9l/ve5s8ndtkRFsDHKDYd+3DpH9dI13TIYsJR9uD yprGyOOq+Fn/OHDECSIRGfPayLBx+z7Y9+WtkCsucg1iCafwTDLR1Ndtnt/O7LAq0DCx rfN4Zxp/7/fDmgEF+b1Gbdi8XXQwXRKt0JFM3x28BKLy20H7MJPE0LvX9wrsQnEGUyZw W/cc2mQjTcA9Nk4awCVIzKLXLBNNl9ioWaFkMBS1MvjvRVFR1OocTsgI6p91ccRdfd75 /NTw== X-Received: by 10.66.145.34 with SMTP id sr2mr1493353pab.94.1373565657750; Thu, 11 Jul 2013 11:00:57 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <4a81b6a6-023e-4d47-9bd0-bbc0516caf6b@googlegroups.com> <56736add-f372-4245-9f50-076b3d44bb00@googlegroups.com> From: Ian Kelly Date: Thu, 11 Jul 2013 12:00:17 -0600 Subject: Re: xslice idea | a generator slice To: Python Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373565668 news.xs4all.nl 15927 [2001:888:2000:d::a6]:42742 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50470 On Thu, Jul 11, 2013 at 10:34 AM, Oscar Benjamin wrote: > On 11 July 2013 17:21, Russel Walker wrote: >> To confess, this is the second time I've made the mistake of trying to i= mplement 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 lo= oking 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. Ah, that's an interesting point. Of course the corollary to that is that xslice requires a sequence, not just an iterable.