Based on your description it seems to be better to extract all files beforehand and read them separately.
Alternatively, would it be possible to call tf.getmembers()
once in your __init__
method or use the filenames stored in your filelist.txt
to get each file using tf.extractfile([self.filelist[index]])
in __getitem__
?
Based on the docs extractfile
should also take a file name directly.