I have a file with thousands of pickle
objects.
I want to access the nth pickled object without having to load all of the preceding objects.
I checked the answers here and here but they don't answer my question. My understanding is that recursive unpickling starts at the top and moves the cursor to the next item after each item is unpickled.
Is it possible to manually specify where the cursor should start so I only unpickle the objects I want?
e.g.
import pickle
with open('file.pkl', 'rb') as f:
for _ in range(2000, 2005):
data = pickle.load(f) # This only loads the first 5 items, not the 2000-2005th items