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


Groups > comp.lang.python > #44087

Re: itertools.groupby

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'output': 0.05; 'memory.': 0.07; '23,': 0.16; 'benjamin': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterators': 0.16; 'lend': 0.16; 'once.': 0.16; 'ought': 0.16; 'sequential': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'preferred': 0.22; 'least': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'constant': 0.31; 'loading': 0.31; 'pipe': 0.31; 'subject:skip:i 10': 0.31; 'allows': 0.31; 'file': 0.32; 'themselves': 0.32; 'text': 0.33; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'more': 0.64; 'importantly,': 0.68; 'oscar': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=At38jvxOGaa1sJD2T1Y+ZceToqRB2OT1Nfwk+aTJNvM=; b=FJ5O2Fkn8sQWpgEtsXOztvkZQTVd7dG9B8VbPZOnNu1PCmtelua7reTuL7fegIxI+D u45Y9zURE3gbGugnB4AFh6kELO6uiVr7QL0hs8NxpMXkPyAyhiAf/OdBnxHj2K/VDD8k W/u3u2Tya9YH3dt3CcGLvJ7zJrZTnx5JXWOdk9DIGgY5MnEf6QXsQ6AJIQ7RaXMm7/Ok NGqZgpXhv7sP1eN8EjVU4xtBeQt1JovcY+3VHGTyCIpFGzkR0vBtNFuaHxH2hfdZa4PC WlBeAuz3BYQyXpyizhhV3Ol/JW/MfJFCqwKdPbkaV7Ps9BAhacF0TgwaET3MZRpLh6Bf f4xQ==
MIME-Version 1.0
X-Received by 10.58.15.193 with SMTP id z1mr19430724vec.40.1366643679927; Mon, 22 Apr 2013 08:14:39 -0700 (PDT)
In-Reply-To <CAHVvXxTG2gfsjrfWAA3LZmAxymcfXHTc9ocb_T+FMU0fqBivJQ@mail.gmail.com>
References <mailman.855.1366477790.3114.python-list@python.org> <atkvgbFto6uU1@mid.individual.net> <CAHVvXxTG2gfsjrfWAA3LZmAxymcfXHTc9ocb_T+FMU0fqBivJQ@mail.gmail.com>
Date Tue, 23 Apr 2013 01:14:39 +1000
Subject Re: itertools.groupby
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.925.1366643689.3114.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366643689 news.xs4all.nl 2268 [2001:888:2000:d::a6]:47188
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44087

Show key headers only | View raw


On Tue, Apr 23, 2013 at 12:49 AM, Oscar Benjamin
<oscar.j.benjamin@gmail.com> wrote:
> Iterators are
> typically preferred over list slicing for sequential text file access
> since you can avoid loading the whole file at once. This means that
> you can process a large file while only using a constant amount of
> memory.

And, perhaps even more importantly, allows you to pipe text in and
out. Obviously some operations (eg grep) lend themselves better to
this than do others (eg sort), but with this it ought at least to
output each group as it comes.

ChrisA

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


Thread

itertools.groupby Jason Friedman <jsf80238@gmail.com> - 2013-04-20 11:09 -0600
  Re: itertools.groupby Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-21 00:13 +0000
    Re: itertools.groupby Joshua Landau <joshua.landau.ws@gmail.com> - 2013-04-22 04:09 +0100
  Re: itertools.groupby Neil Cerutti <neilc@norwich.edu> - 2013-04-22 14:24 +0000
    Re: itertools.groupby Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-22 15:49 +0100
      Re: itertools.groupby Neil Cerutti <neilc@norwich.edu> - 2013-04-22 15:04 +0000
    Re: itertools.groupby Chris Angelico <rosuav@gmail.com> - 2013-04-23 01:14 +1000

csiph-web