Scanning a file

Gerhard Häring gh at
Fri Oct 28 13:21:07 CEST 2005

pinkfloydhomer at wrote:
> I want to scan a file byte for byte [...]
> while True:
>     ch =
> [...] 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.

-- Gerhard

More information about the Python-list mailing list