3 ms·
Fairly picking a line out of a text file isn't constant time. It depends on the length of the file. You can pick a random byte offset and find the next line bu
by kevincox 4y ago
Fairly picking a line out of a text file isn't constant time. It depends on the length of the file.
You can pick a random byte offset and find the next line but this prefers longer lines.
Preprocessing to basically make a table of line offsets allows constant time access.
Probably mattered more when storage was slower.