Why is reading one byte 20x slower than reading 2, 3, 4, … bytes from a file?
I have been trying to understand the tradeoff between read and seek . For small "jumps" reading unneeded data is faster than skipping it with seek . While timing different read/seek chunk sizes to find the tipping point, I came across a odd phenomenon: read(1) is about 20 times slower than read(2) , read(3) , etc. This effect is the same for different read methods, e.g. read() and readinto() . Why is this the case? Search in the timing results for the following line 2/3 of the way through: 2 x buffered 1 byte readinto bytearray Environment: Python 3.5.2 |Continuum Analytics, Inc.| (default,