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

References (4 earlier) <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 2013-09-19 15:48 +0100
Subject Re: iterating over a file with two pointers
Newsgroups comp.lang.python
Message-ID <mailman.152.1379602164.18130.python-list@python.org> (permalink)

Show all headers | 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