I plan to store an array of numbers in a file and read it when needed. What would be a good way to do this? I can think of afew ways such as storing each element in a line as a text file or serialize it and store / call by that method. Speed is my first concern.
Thanks
If the file doesn’t need to be human-readable, then serializing it would be the better approach performance wise.
If you would save every array entry as a line in a file, you would need to traverse the array,
do some IO, save the file, later to restore it as the exact same array you would need to do all thos steps in reverse.
Furthermore, IO operations are fairly expensive.
The built-in serialization mechanism does all this for you and arguably in the most effective way possible.