3 ms·
I have fortunes in a text file, one per line, and a simple python script which picks a random one and puts it into my signature file. I never understood why for
by twic 4y ago
I have fortunes in a text file, one per line, and a simple python script which picks a random one and puts it into my signature file. I never understood why fortune needed a binary format with a preparation step. Because machines had far less memory back in the old days?
- kevincox 4y agoFairly 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.