How to do this in Python?

bieffe62 at gmail.com bieffe62 at gmail.com
Wed Mar 18 03:59:43 EDT 2009


On Mar 18, 2:00 am, Jim Garrison <j... at acm.org> 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
application
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.

Ciao
----
FB



More information about the Python-list mailing list