Purpose of ReindexCollection call in LMDataloader

Hi

I was digging through the fastcore source code to get a better understanding of language model data preprocessing (LMdataloader) and came across the ReindexCollection function.

I see that this class implements caching. I assume this makes the dataloading faster but I can’t work out how. Would someone be able to explain a bit more about that?

Thanks