I'm now down to: f = open("filename", "rb") s = f.read() sub = "\x00\x00\x01\x00" count = s.count(sub) print count
Which is quite fast. The only problems is that the file might be huge. I really have no need for reading the entire file into a string as I am doing here. All I want is to count occurences this substring. Can I somehow count occurences in a file without reading it into a string first? /David -- http://mail.python.org/mailman/listinfo/python-list