def fnd(fname, s, start=0):
    with open(fname, 'rb') as f:
        fsize = os.path.getsize(fname)
bsize = 4096
buffer = None
if start > 0:
    f.seek(start)
overlap = len(s) - 1
while True:
    if f.tell() >= overlap and f.tell() < fsize:
        f.seek(f.tell() - overlap)
buffer = f.read(bsize)
if buffer:
    pos = buffer.find(s)
if pos >= 0:
    return f.tell() - (len(buffer) - pos)
else:
    return -1
Дешевый способ поиска строки в большом текстовом файле