I am trying to bijectively map a range of indices to another set of indices. So I came up with this:
def get_index(i):
# Does more complicated stuff, but just to illustrate.
return 2*i + 1
my_iterator = iter(get_index(i) for i in range(100))
# then I use my_iterator
for a in my_iterator:
...
Now I would like to provide a randomly permuted version of this iterator (without repetition) and my question is how to do that without having to explicit the range into a list. The number of elements is huge and I would not like to store the whole thing in memory.
Aucun commentaire:
Enregistrer un commentaire