@TaranRai … while I’m not a big h5 person, I’m pretty sure the way you’re using it will be very slow by default. I assume h5py.File does an open and likely some sort of scan/index of the data file (which contains many entries and may be quite slow). You should likely be doing an operating like that once in the __init__ method and then just doing the index lookup in getitem/len.
Depending on whether the h5py file object is safe to copy and access from multiple processes, you may want to do a lazy load of the file, defer it until first __getitem__ call, but still only do it once per loader-worker.