I have been trying to understand the tradeoff between read
and seek
. For small \"jumps\" reading unneeded data is faster than skipping it with se
I was able to reproduce the issue with your code. However, I noticed the following: can you verify that the issue disappears if you replace
file.seek(randint(0, file.raw._blksize), 1)
with
file.seek(randint(0, file.raw._blksize), 0)
in setup
? I think you might just run out of data at some point during reading 1 byte. Reading 2 bytes, 3 bytes and so on won't have any data to read, so that's why it's much faster.