From: Konrad Meyer Date: 2007-10-28T17:18:18+09:00 Subject: Re: NOT reading an entire file into memory --nextPart6708284.t5Ny6Zu6aX Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Quoth 7stud --: > Konrad Meyer wrote: > > Quoth 7stud --: > >> #create a data file containing: > >>=20 > >> else > >> break > >> end > >>=20 > >> end > >> end > >=20 > > IO#each_with_index and IO#readline are probably the same internally, so= =20 > > the > > real answer here is that NO, IO#readline is NOT the same as > > File.read.split('\n'), that's IO#readlines. > > >=20 > The real question is: does readline do any buffering? What about=20 > each()? If a file has ten lines in it, does ruby access the file ten=20 > times? Or, does ruby read some reasonable amount of data into a buffer? Performance isn't everything. If it was, you wouldn't be using ruby. The id= ea=20 is that this will work "well enough", shouldn't take too much thought on th= e=20 programmer's behalf, and doesn't load the entire (huge) file into ram. =2D-=20 Konrad Meyer http://konrad.sobertillnoon.com/ --nextPart6708284.t5Ny6Zu6aX Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBHJEXCCHB0oCiR2cwRAt4sAKC3UYPEDVZZNMIfCsJthMT2Y8HuswCdFAd0 tb77cWABNbZlQ/CvwDNYlx8= =vQVZ -----END PGP SIGNATURE----- --nextPart6708284.t5Ny6Zu6aX--