Note that the programs are not identical since read
moves the cursor position! So you want to call f.seek(-20, 1)
unless you want to read the same 10 bytes over and over.
Also, the additional call to ftell
may make the first one (imperceptibly) slower. Another difference between your programs is that they behave slightly differently if the file is being written to while you're reading it.
Also note that you can directly seek from EOF, like this:
with open('myfile', 'rb') as f:
f.seek(-10, 2) # Seek from EOF
print(f.read(10))
f.seek(-20, 1)
print(f.read(10))
f.seek(-20, 1)
print(f.read(10))