Storing 10GB in memory is never a good idea, I recommend you write the samples to csv-files or something alike an then use a read function to read the samples from the csv-files in __getitem(self, i)__