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


Groups > comp.lang.python > #50475

Re: xslice idea | a generator slice

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <fabiosantosart@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'builtin': 0.09; 'iterate': 0.09; 'cc:addr:python-list': 0.11; 'assume': 0.14; 'itertools': 0.16; 'looping': 0.16; 'python-level': 0.16; '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; 'memory': 0.22; 'cc:addr:gmail.com': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; '(or': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; '&gt;': 0.26; 'second': 0.26; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'thus': 0.29; "doesn't": 0.30; 'start,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'implemented': 0.33; 'could': 0.34; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'too': 0.37; 'step': 0.37; 'implement': 0.38; 'negative': 0.60; 'july': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'jul': 0.74; 'increase': 0.74; 'faster.': 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:date:message-id:subject:from:to :cc:content-type; bh=+ST6FuKptzb1op3LJA1VTBfU02CRVck+crcrAwXzCzc=; b=gPB0ZWvgywokZiXvCnvcWCpCyVPyZ2m1oFgTzZkhXmvYnl2rlXoKv/9sewdNYMoRZS fHtBnG9o045hH2Hy7tuDJ62O0b24w5M+f+GQAyy2ZEJUtI3urmWoH7Aa09mvEScwSlSP 1f9/cp21Y5nk5nTSrd/vjaJNACaqh2aWDcusqDur+YqrIiv7jt/KnZmx5TBRe85NG39G IlG2SDc94EA2jcpcC/vPA2NKnmw/raDikul9smjcZcZ/dJdH8dPaMLM8FySaQbOyrFkp BWz0hQ5GbscfbRvbylnBdPZhnHP27HVmpKnVSW0VXBoAiaNuWFzySvZmZg1imn5QyUf9 paUg==
MIME-Version 1.0
X-Received by 10.229.214.132 with SMTP id ha4mr7502214qcb.20.1373572729474; Thu, 11 Jul 2013 12:58:49 -0700 (PDT)
In-Reply-To <CAHVvXxSDQwk1KVLETetOz5EiNK3BjTD=6px_L9SFfcpfbhuYzA@mail.gmail.com>
References <4a81b6a6-023e-4d47-9bd0-bbc0516caf6b@googlegroups.com> <c087829a-8e30-4f50-afb9-d28a779932e3@googlegroups.com> <mailman.4590.1373555714.3114.python-list@python.org> <56736add-f372-4245-9f50-076b3d44bb00@googlegroups.com> <CAHVvXxSDQwk1KVLETetOz5EiNK3BjTD=6px_L9SFfcpfbhuYzA@mail.gmail.com>
Date Thu, 11 Jul 2013 20:58:49 +0100
Subject Re: xslice idea | a generator slice
From Fábio Santos <fabiosantosart@gmail.com>
To Oscar Benjamin <oscar.j.benjamin@gmail.com>
Content-Type multipart/alternative; boundary=001a1133232a9d16f804e141d232
Cc python-list@python.org, Russel Walker <russ.pobox@gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.4601.1373572738.3114.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373572738 news.xs4all.nl 15934 [2001:888:2000:d::a6]:47712
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50475

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 11 Jul 2013 17:38, "Oscar Benjamin" <oscar.j.benjamin@gmail.com> wrote:
>
> On 11 July 2013 17:21, Russel Walker <russ.pobox@gmail.com> wrote:
> > To confess, this is the second time I've made the mistake of trying to
implement 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
looking 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.

Isn't all of itertools implemented in C? If we are not using a python-level
and not-so-fast __getitem__ I would wager the C version is a lot faster.

And if the input is indexable could I assume that it is not too large to
have around in memory and thus any speed increase in looping over it would
be tiny?

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


Thread

xslice idea | a generator slice Russel Walker <russ.pobox@gmail.com> - 2013-07-11 07:52 -0700
  Re: xslice idea | a generator slice Russel Walker <russ.pobox@gmail.com> - 2013-07-11 07:54 -0700
    Re: xslice idea | a generator slice Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-07-11 16:14 +0100
      Re: xslice idea | a generator slice Russel Walker <russ.pobox@gmail.com> - 2013-07-11 09:21 -0700
        Re: xslice idea | a generator slice Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-07-11 17:34 +0100
        Re: xslice idea | a generator slice Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-11 12:00 -0600
        Re: xslice idea | a generator slice Fábio Santos <fabiosantosart@gmail.com> - 2013-07-11 20:58 +0100
        Re: xslice idea | a generator slice Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-11 15:02 -0600
  Re: xslice idea | a generator slice Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-11 10:16 -0600

csiph-web