lundi 19 novembre 2018

random.shuffle very slow in Python 3 with list

I am using python-3.x, and I am trying to generate a list of indexes numbers and shuffle them to use them later to select random values from a sample where this sample will have two variables sample size and dimension number, however here how I generate a list of indexes and them I shuffle them:

dimension = 5
sample_size = 100

generate_indexes = itertools.combinations(range(sample_size),dimension)
all_indexes = list(generate_indexes)

# here I do the shuffle
random.shuffle(all_indexes)

the problem when I increased the dimension number it will take a long time to give the result even if the dimension number is 5 it takes very long or it will not proceed.

Is there any way to make it fast?




Aucun commentaire:

Enregistrer un commentaire