File Index¶
MicPy offers an indexing mechanism that can significantly enhance the performance of the reading process for binary files. When you first open a binary file with MicPy, the library creates an index of the file's contents. This index is stored in memory, speeding up subsequent read operations.
The following plot compares the time required to read individual fields from a binary file with and without indexing. As can be seen, the indexing mechanism makes sure that the time required to read a field is almost constant, regardless of the field's position in the file.
It's important to note that the effectiveness of this indexing mechanism relies on the file remaining open. If you close the file, the index is lost, and the library will need to recreate it the next time you open the file. This is why it's recommended to keep the file open while you're working with it.