From: Steve Midgley Date: 2007-12-06T10:07:46+09:00 Subject: Reasons to use a buffer in IO::read? Hi Ruby people, I'm wondering what the functional and performance differences might be between the two statements below? Assume 'io' is an IO instance with gobs of data in it. Assume 'file' is an open file instance with write access: until io.eof? do file.write(io.read(10485760)) end buffer = '' until io.eof? do buffer = io.read(10485760) file.write(buffer) end I see that Ruby provides for a buffer and I'm wondering what the reason is? I read this article but am still not clear on the benefit of a buffer at all: http://rcoder.net/content/fast-ruby-io I'm wondering if providing a buffer might reduce malloc issues and speed things up? I can't see any other reason to use one.. Thanks in advance for any information! Steve