Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47818
| Path | csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'true,': 0.05; 'subject:two': 0.07; '[],': 0.09; 'builtin': 0.09; 'iterate': 0.09; 'subject:into': 0.09; 'cc:addr:python-list': 0.11; 'expression.': 0.16; 'iterator': 0.16; 'lambda': 0.16; 'path:': 0.16; 'smith"': 0.16; 'subject:based': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'memory': 0.22; 'cc:addr:python.org': 0.22; 'rid': 0.24; 'cc:2**0': 0.24; 'pass': 0.26; 'least': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'constant': 0.31; 'url:python': 0.33; 'continuing': 0.33; 'could': 0.34; 'requirement': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'list': 0.37; 'skip:o 20': 0.38; '8bit%:86': 0.38; 'pm,': 0.38; 'anything': 0.39; '12,': 0.39; 'sure': 0.39; 'url:mail': 0.40; 'to:addr:gmail.com': 0.65; 'phil': 0.84; 'usage.': 0.84; '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:content-transfer-encoding; bh=TENzQylyIg/aUa0VzJsIcEZHnRo2e9jQQsKQTVi8N98=; b=stgVlr8inMrCDHMwmhNG2L/sIGt2fvxMNhIDCGFxbHfIh7MAmRKgMmPH1o5GamVC+r Gzniluxhn74oyLv5AM6rq3CLoJ84gdIeir3aREtpWay/14iTjrlofmz1xlZGVQ/IMnPx GKOvNN7u0l2bXZdX7owlHkdvcmVzVl/xKRayunMplo5diViI9i9sLPrq2wGHl1CVl8C5 jjuIg1QMtf2yMx0kM5dqelWnstdlqiKdRnnnG0HhXbjnasut/yEkbGZFYWXHWMgXCKzp eLAQ7aH3mi2WNGl+Ocmo2ycveKpC/eOBvYr2tqKZo6Km3mmBr20sb387IntdrvX5T+V6 KsVg== |
| MIME-Version | 1.0 |
| X-Received | by 10.224.214.134 with SMTP id ha6mr25181438qab.77.1371056240561; Wed, 12 Jun 2013 09:57:20 -0700 (PDT) |
| In-Reply-To | <kpa7jo$3um$1@ger.gmane.org> |
| References | <kp5d9e$2hf$1@panix2.panix.com> <mailman.2992.1370904643.3114.python-list@python.org> <roy-12F8FA.00111311062013@news.panix.com> <mailman.3023.1370964449.3114.python-list@python.org> <roy-10ED1B.20334411062013@news.panix.com> <CANCy3MzHXNp-m-fKiOr0A+=gvwUgoQS2KaWuWjGgStfk+JQsbQ@mail.gmail.com> <kpa7jo$3um$1@ger.gmane.org> |
| Date | Wed, 12 Jun 2013 17:57:20 +0100 |
| Subject | Re: Split a list into two parts based on a filter? |
| From | Fábio Santos <fabiosantosart@gmail.com> |
| To | Serhiy Storchaka <storchaka@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | "python-list@python.org" <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 <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.3114.1371056243.3114.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1371056243 news.xs4all.nl 15959 [2001:888:2000:d::a6]:48239 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:47818 |
Show key headers only | View raw
Why is there no builtin to consume a generator? I find that odd. On Wed, Jun 12, 2013 at 5:28 PM, Serhiy Storchaka <storchaka@gmail.com> wrote: > 12.06.13 09:32, Phil Connell написав(ла): >> >> On 12 Jun 2013 01:36, "Roy Smith" <roy@panix.com <mailto:roy@panix.com>> >> >> wrote: >> > Well, continuing down this somewhat bizarre path: >> > >> > new_songs, old_songs = [], [] >> > itertools.takewhile( >> > lambda x: True, >> > (new_songs if s.is_new() else old_songs).append(s) for s in songs) >> > ) >> > >> > I'm not sure I got the syntax exactly right, but the idea is anything >> > that will iterate over a generator expression. That at least gets rid >> > of the memory requirement to hold the throw-away list :-) >> >> You could equivalently pass the generator to deque() with maxlen=0 - >> this consumes the iterator with constant memory usage. > > > any((new_songs if s.is_new() else old_songs).append(s) for s in songs) > > > -- > http://mail.python.org/mailman/listinfo/python-list -- Fábio Santos
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Split a list into two parts based on a filter? roy@panix.com (Roy Smith) - 2013-06-10 16:34 -0400
Re: Split a list into two parts based on a filter? Chris Angelico <rosuav@gmail.com> - 2013-06-11 08:50 +1000
Re: Split a list into two parts based on a filter? Roel Schroeven <roel@roelschroeven.net> - 2013-06-11 00:50 +0200
Re: Split a list into two parts based on a filter? Roy Smith <roy@panix.com> - 2013-06-11 00:11 -0400
Re: Split a list into two parts based on a filter? Serhiy Storchaka <storchaka@gmail.com> - 2013-06-11 18:27 +0300
Re: Split a list into two parts based on a filter? Roy Smith <roy@panix.com> - 2013-06-11 20:33 -0400
Re: Split a list into two parts based on a filter? Phil Connell <pconnell@gmail.com> - 2013-06-12 07:32 +0100
Re: Split a list into two parts based on a filter? Roy Smith <roy@panix.com> - 2013-06-12 07:39 -0400
Re: Split a list into two parts based on a filter? Fábio Santos <fabiosantosart@gmail.com> - 2013-06-12 12:51 +0100
Re: Split a list into two parts based on a filter? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-06-12 15:06 +0300
Re: Split a list into two parts based on a filter? Terry Reedy <tjreedy@udel.edu> - 2013-06-12 14:07 -0400
Re: Split a list into two parts based on a filter? Serhiy Storchaka <storchaka@gmail.com> - 2013-06-12 19:28 +0300
Re: Split a list into two parts based on a filter? Fábio Santos <fabiosantosart@gmail.com> - 2013-06-12 17:57 +0100
Re: Split a list into two parts based on a filter? Terry Reedy <tjreedy@udel.edu> - 2013-06-12 14:47 -0400
Re: Split a list into two parts based on a filter? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-06-13 10:43 +0100
Re: Split a list into two parts based on a filter? Chris Rebert <clp2@rebertia.com> - 2013-06-10 16:03 -0700
Re: Split a list into two parts based on a filter? Tim Chase <python.list@tim.thechases.com> - 2013-06-10 18:10 -0500
Re: Split a list into two parts based on a filter? Fábio Santos <fabiosantosart@gmail.com> - 2013-06-11 00:08 +0100
Re: Split a list into two parts based on a filter? alex23 <wuwei23@gmail.com> - 2013-06-11 17:44 -0700
Re: Split a list into two parts based on a filter? Chris Angelico <rosuav@gmail.com> - 2013-06-11 09:12 +1000
Re: Split a list into two parts based on a filter? Peter Otten <__peter__@web.de> - 2013-06-11 02:11 +0200
Re: Split a list into two parts based on a filter? Peter Otten <__peter__@web.de> - 2013-06-11 08:43 +0200
Re: Split a list into two parts based on a filter? Jonas Geiregat <jonas@geiregat.org> - 2013-06-11 08:47 +0200
Re: Split a list into two parts based on a filter? Fábio Santos <fabiosantosart@gmail.com> - 2013-06-11 14:48 +0100
Re: Split a list into two parts based on a filter? rusi <rustompmody@gmail.com> - 2013-06-11 09:37 -0700
Re: Split a list into two parts based on a filter? Fábio Santos <fabiosantosart@gmail.com> - 2013-06-11 18:05 +0100
Re: Split a list into two parts based on a filter? rusi <rustompmody@gmail.com> - 2013-06-11 10:23 -0700
Re: Split a list into two parts based on a filter? Chris Angelico <rosuav@gmail.com> - 2013-06-12 03:37 +1000
Re: Split a list into two parts based on a filter? rusi <rustompmody@gmail.com> - 2013-06-11 11:13 -0700
Re: Split a list into two parts based on a filter? Fábio Santos <fabiosantosart@gmail.com> - 2013-06-11 19:05 +0100
Re: Split a list into two parts based on a filter? Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-11 15:22 +0100
Re: Split a list into two parts based on a filter? Serhiy Storchaka <storchaka@gmail.com> - 2013-06-11 18:28 +0300
Re: Split a list into two parts based on a filter? Chris Angelico <rosuav@gmail.com> - 2013-06-12 03:28 +1000
Re: Split a list into two parts based on a filter? Roy Smith <roy@panix.com> - 2013-06-11 20:12 -0400
Re: Split a list into two parts based on a filter? Peter Otten <__peter__@web.de> - 2013-06-11 20:13 +0200
Re: Split a list into two parts based on a filter? Peter Otten <__peter__@web.de> - 2013-06-11 20:18 +0200
Re: Split a list into two parts based on a filter? Chris Angelico <rosuav@gmail.com> - 2013-06-12 04:27 +1000
Re: Split a list into two parts based on a filter? Roel Schroeven <roel@roelschroeven.net> - 2013-06-11 22:22 +0200
csiph-web