Fair enough to enquire about performance, especially relative to similar
languages.  However, you simply shouldn't expect to be able to read 4MB and
create such a large data structure (i.e. an array with thousands of
elements) in a quick time.

If you expect the file to be large, you really should try to read it a line
at a time:

while line = file.gets
  # Process "line"
end

(or similar)

Cheers,
Gavin


----- Original Message -----
From: "Shashank Date" <ADATE / kc.rr.com>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Friday, August 02, 2002 11:33 AM
Subject: IO.readlines is slow ?


> 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.
>
> (Similar constructs are much faster in Python and Perl world).
>
> Please help.
>
> -- Shanko
>
>
>
>
>