while b < len(haystack) - 1024:
    if H[b] != k:
        return 'not found'
if needle == haystack[b:b + 1024]:
    return 'found at', b
ib += 1
b = B[ib]
Fastest way to search 1GB+ a string of data for the first occurence of a pattern in Python