f.seek(p)
buf = f.read(sz) + remainder
if '\n' not in buf:
    remainder = buf
else:
    i = buf.index('\n')
for L in buf[i + 1:].split('\n')[::-1]:
    yield L
remainder = buf[:i]
if p == 0:
    break
yield remainder
How to read file in reverse order in python3.2 without reading the whole file to memory?