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


Groups > comp.lang.python > #54426

Re: iterating over a file with two pointers

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@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.01; 'amounts': 0.07; 'discard': 0.07; 'memory.': 0.07; 'subject:file': 0.07; 'subject:two': 0.07; 'okay': 0.09; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'wrote': 0.14; '2.7': 0.14; 'cc:name:python list': 0.16; 'to:addr:web.de': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'script': 0.25; 'task': 0.26; 'header:In-Reply-To:1': 0.27; 'quickly': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'follows': 0.31; 'running': 0.33; 'maybe': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'depends': 0.38; 'massive': 0.38; 'how': 0.40; 'introduced': 0.61; 'believe': 0.68; '(according': 0.84; 'blow': 0.84; 'manager).': 0.84; 'oscar': 0.84; 'otten': 0.84; 'subject:over': 0.84; 'imagine': 0.93; '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 :cc:content-type; bh=gsqVJHZx2nx+OyF0SGRhgzDcW8bdvUK44Xbxnh3NfPo=; b=U8Og0ZHD33YE/QaV5rFv4LDVUwSI7e7oVgxrDmm3AOq4uUoun4vpSzQOd0Nedykle1 ckyHggw72L7B0fqOLG6kIFydHpYPEbkKj+/jfArdytMLNvx7xGDN8H5zu50IPlybV9eZ RkWWA1+krVO+PNUOUxNJHofjGx3+ylCrJKWiaYLPiic3uwNaz7YoeN8cnxGBKRrS6Di2 yv9xQG/nDy7LcmAqB5RBJjGvYcsjVlJbr8mv2KgFA6MT6Jya80WMZtRHZZ80gyfjIp+Y 9xhv/E3oVwLj9dXfglIpDZBLbrY+RgVbtJtKrSLkHOFaXYEoc7un1eLEfcX8elsH/taa V0Jg==
X-Received by 10.52.24.4 with SMTP id q4mr444753vdf.34.1379602153810; Thu, 19 Sep 2013 07:49:13 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <l1f27c$onv$1@ger.gmane.org>
References <3018b3d4-f914-4c89-9f26-cd4b2af32e73@googlegroups.com> <CAPTjJmoyrJqVR29MeDzcfA9K=gGgHSuqO3uCNXGLQs7APLJByA@mail.gmail.com> <mailman.115.1379504419.18130.python-list@python.org> <roy-B13238.08561818092013@news.panix.com> <CAHVvXxQa6rsrD669kL-EeqCQFn3jKH-k=eWY5iey4RwVBD2RiA@mail.gmail.com> <52B7F7EA-C7C4-4DB6-A93C-25F4C058EB58@panix.com> <l1e8ol$99q$1@ger.gmane.org> <CAHVvXxQXqvKr5eoxGmYgbQMPt-N6eZRT50EBOjOuVYu_DbCQMQ@mail.gmail.com> <l1f27c$onv$1@ger.gmane.org>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date Thu, 19 Sep 2013 15:48:53 +0100
Subject Re: iterating over a file with two pointers
To Peter Otten <__peter__@web.de>
Content-Type text/plain; charset=ISO-8859-1
Cc Python List <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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.152.1379602164.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1379602164 news.xs4all.nl 15875 [2001:888:2000:d::a6]:32865
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:54426

Show key headers only | View raw


On 19 September 2013 15:38, Peter Otten <__peter__@web.de> wrote:
>> While running the above python.exe was using 6MB of memory (according
>> to Task Manager). I believe this is because tee() works as follows
>> (which I made up but it's how I imagine it).
>
> [...]
>
>> However, when I ran the above script on Python 2.7 it did consume
>> massive amounts of memory (1.6GB) and ran slower so maybe this depends
>> on optimisations that were introduced in 3.x.
>
> Did you use xrange()?

No I didn't. :)

Okay so it only uses 4.6MB of memory and it runs at the same speed:
there's no problem with chaining tee objects as long as you discard
them. If you don't discard them then a script like the one I wrote
would quickly blow all the system memory.


Oscar

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


Thread

iterating over a file with two pointers nikhil Pandey <nikhilpandey90@gmail.com> - 2013-09-18 04:12 -0700
  Re: iterating over a file with two pointers Chris Angelico <rosuav@gmail.com> - 2013-09-18 21:21 +1000
    Re: iterating over a file with two pointers nikhil Pandey <nikhilpandey90@gmail.com> - 2013-09-18 05:07 -0700
      Re: iterating over a file with two pointers Travis Griggs <travisgriggs@gmail.com> - 2013-09-18 09:18 -0700
  Re: iterating over a file with two pointers Dave Angel <davea@davea.name> - 2013-09-18 11:39 +0000
    Re: iterating over a file with two pointers Roy Smith <roy@panix.com> - 2013-09-18 08:56 -0400
      Re: iterating over a file with two pointers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-18 14:09 +0100
      Re: iterating over a file with two pointers Roy Smith <roy@panix.com> - 2013-09-18 10:36 -0400
      Re: iterating over a file with two pointers Dave Angel <davea@davea.name> - 2013-09-18 20:07 +0000
      Re: iterating over a file with two pointers Peter Otten <__peter__@web.de> - 2013-09-19 09:23 +0200
      Re: iterating over a file with two pointers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-19 15:16 +0100
      Re: iterating over a file with two pointers Peter Otten <__peter__@web.de> - 2013-09-19 16:38 +0200
      Re: iterating over a file with two pointers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-19 15:48 +0100
  Re: iterating over a file with two pointers Peter Otten <__peter__@web.de> - 2013-09-18 13:44 +0200
    Re: iterating over a file with two pointers nikhil Pandey <nikhilpandey90@gmail.com> - 2013-09-18 05:14 -0700
      Re: iterating over a file with two pointers Peter Otten <__peter__@web.de> - 2013-09-18 14:54 +0200
      Re: iterating over a file with two pointers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-19 02:40 +0000
  Re: iterating over a file with two pointers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-19 02:56 +0000
    Re: iterating over a file with two pointers Joshua Landau <joshua@landau.ws> - 2013-09-19 08:04 +0100

csiph-web