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


Groups > comp.lang.python > #31973 > unrolled thread

Re: Fast forward-backward (write-read)

Started byemile <emile@fenx.com>
First post2012-10-23 16:35 -0700
Last post2012-10-23 16:35 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Fast forward-backward (write-read) emile <emile@fenx.com> - 2012-10-23 16:35 -0700

#31973 — Re: Fast forward-backward (write-read)

Fromemile <emile@fenx.com>
Date2012-10-23 16:35 -0700
SubjectRe: Fast forward-backward (write-read)
Message-ID<mailman.2702.1351035353.27098.python-list@python.org>
On 10/23/2012 04:19 PM, David Hutto wrote:
> Whether this is fast enough, or not, I don't know:

well, the OP's original post started with
   "I am working with some rather large data files (>100GB)..."

> filename = "data_file.txt"
> f = open(filename, 'r')
> forward =  [line.rstrip('\n') for line in f.readlines()]

f.readlines() will be big(!) and have overhead... and forward results in 
something again as big.

> backward =  [line.rstrip('\n') for line in reversed(forward)]

and defining backward looks to me to require space to build backward and 
hold reversed(forward)

So, let's see, at that point in time (building backward) you've got
probably somewhere close to 400-500Gb in memory.

My guess -- probably not so fast.  Thrashing is sure to be a factor on 
all but machines I'll never have a chance to work on.


> f.close()
> print forward, "\n\n", "********************\n\n", backward, "\n"


It's good to retain context.

Emile

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web