On Thursday 01 August 2002 06:33 pm, Shashank Date wrote:
> I really like the convenience of doing:
>
> arr = IO.readlines("test1.txt")
>
> and then using [arr] to massage my data.
>
> But, when "test1.txt" is a big file (say 4MB) it takes for ever to
> read the file.
>
> Is there any way to make it faster without sacrificing the
> terseness.

On my machine it takes 0.1 seconds or so to read a 4Mb file made
up of 128 byte lines.

In fact, it's faster than Perl:

$ time perl -e "open(F,'bigfile');@a=<F>"

real    0m0.239s
user    0m0.170s
sys     0m0.060s

$ time ruby -e "a=IO.readlines('bigfile')"

real    0m0.152s
user    0m0.130s
sys     0m0.010s

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE