how to search multiple textfiles ? (Python is slow ?)

Stef Mientki stef.mientki at gmail.com
Fri Sep 26 23:26:54 CEST 2008


Mike Driscoll wrote:
> On Sep 26, 8:35 am, Stef Mientki <s.mien... at ru.nl> wrote:
>   
>> hello,
>>
>> I want to search multiple textfiles (python source files) for a specific
>> word.
>> I can find all files, open them and do a search,
>> but I guess that will be rather slow.
>>
>> I couldn't find any relevant information through google.
>>
>> Does anyone know of a search library that performs this task fast ?
>>
>> If it indeed only concerns py-files,
>> is there another way of searching words ?
>> ( I could imagine that such a "py-only-search" would have benefits,
>> because you could set a flag to see the words in comment yes or no )
>>
>> thanks,
>> Stef Mientki
>>
>> Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629.
>> The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629.
>>     
>
>
> On Windows I use the free version of Bare Grep: http://www.baremetalsoft.com/baregrep/
>
> No, it's not a Python solution, but it works for my needs. You should
> try using Python to search your script files and see if it really is
> too slow though.
>   
hi guys,
I did some tests and I'm amazed about the results:

I did a search on the Python directory: 300 MB, 10325 files in 660 folders.

I did several searches, with / without case-sensitive, whole words / 
not, many/few occurrences,
but the differences between those were negligible.

Finding all occurences with line numbers:
- Pyscripter 110 sec ( PyScripter is the default IDE I use now)
- Delphi  20 .. 35 sec
- Findstr  4 sec

With the following programs I only searched for the first occurence,
which I think is good in the case of many files, because you can only 
view 20 or 30 lines in 1 screen.
- Explorer XXX didn't find anything
- FileNurse 5 sec  (FileNurse is my own Explorer replacement, written in 
Delphi)
- Python 3 sec (very quick and dirty procedure with string.find method

I'm really amazed by the speed of Python !!
It can only be beaten by findstr, which is only available on windows.

Paul: nucular looks very promissing, but I couldn't get it working 
within a few minutes. I might also be a little overkill,
but I'll certainly bookmark the link for future use.

thanks again,
cheers,
Stef


> Mike
> --
> http://mail.python.org/mailman/listinfo/python-list
>   




More information about the Python-list mailing list