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: 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: References: Date: Tue, 23 Apr 2013 01:14:39 +1000 Subject: Re: itertools.groupby From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Tue, Apr 23, 2013 at 12:49 AM, Oscar Benjamin 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