Search for a string in binary files

Isaac To kkto at csis.hku.hk
Tue Jul 22 21:08:29 EDT 2003


>>>>> "François" == François Pinard <pinard at iro.umontreal.ca> writes:

    François> [hokieghal99]
    >> One last question: does grep actually open files when it searches
    >> them?

    François> I did not look at `grep' sources for a good while, I might not
    François> remember correctly, read me with caution.  `grep' might be
    François> trying to `mmap' the files if the file (and the underlying
    François> system) allows this, and there is system overhead associated
    François> with that function, just like `open'.

Mmap requires the file descriptor of the file as argument, so the file still
has to be opened.  In general "open" is the OS interface to request for
access to file data, so there is no way around it.

Regards,
Isaac.




More information about the Python-list mailing list