Scanning a file
jeremy+complangpython at jeremysanders.net
Fri Oct 28 16:37:46 CEST 2005
Gerhard Häring wrote:
> pinkfloydhomer at gmail.com wrote:
>> I want to scan a file byte for byte [...]
>> while True:
>> ch = inputFile.read(1)
>> [...] But it is very slow. What is the fastest way to do this? Using some
>> native call? Using a buffer? Using whatever?
> Read in blocks, not byte for byte. I had good experiences with block
> sizes like 4096 or 8192.
It's difficult to handle overlaps. The four byte sequence may occur at the
end of one block and beginning of the next. You'd need to check for these
More information about the Python-list