python vs. grep

Ville M. Vainio vivainio at gmail.com
Tue May 13 02:17:19 EDT 2008


Ricardo Aráoz <ricaraoz at gmail.com> writes:

> The easy/simple (too easy/simple?) way I see out of it is to read THE
> WHOLE file into memory and don't worry. But what if the file is too

The easiest and simplest approach is often the best with
Python. Reading in the whole file is rarely too heavy, and you omit
the python "object overhead" entirely - all the code executes in the
fast C extensions.

If the file is too big, you might want to look up mmap:

http://effbot.org/librarybook/mmap.htm



More information about the Python-list mailing list