timeit("x=islice(open('afile'), 4003, 4005); print next(x) + next(x)",
    'from itertools import islice', number=1)
timeit("print getline('afile', 4003) + getline('afile', 4004)",
    'from linecache import getline', number=1)
Python fastest access to line in file