Looking for lots of words in lots of files
Martin P. Hellwig
xng at xs4all.nl
Wed Jun 18 11:57:47 EDT 2008
Kris Kennaway wrote:
<cut>
>
> If you can't use an indexer, and performance matters, evaluate using
> grep and a shell script. Seriously.
>
> grep is a couple of orders of magnitude faster at pattern matching
> strings in files (and especially regexps) than python is. Even if you
> are invoking grep multiple times it is still likely to be faster than a
> "maximally efficient" single pass over the file in python. This
> realization was disappointing to me :)
>
> Kris
Adding to this:
Then again, there is nothing wrong with wrapping grep from python and
revert to a pure python 'solution' if the system has no grep.
Reinventing the wheel is usually only practical if the existing ones
aren't round :-)
--
mph
More information about the Python-list
mailing list