How to do this in Python?

bieffe62 at bieffe62 at
Wed Mar 18 08:59:43 CET 2009

On Mar 18, 2:00 am, Jim Garrison <j... at> wrote:

>  I don't want "for line in f:" because binary
> files don't necessarily have lines and I'm bulk processing
> files potentially 100MB and larger.  Reading them one line
> at a time would be highly inefficient.
> Thanks- Hide quoted text -
> - Show quoted text -

For what I know, there are at least two levels of cache between your
and the actual file: python interpreter caches its reads, and the
operating system
does that too. So if you are worried about reading efficiently the
file, I think you can stop
worry. Instead, if you are processing files which might not have line
termination at all,
then reading in blocks is the right thing to do.


More information about the Python-list mailing list