The () method in python can randomly extract N distinct elements from a specified list, but in practice it has been found that the method executes slowly when the value of N is relatively large, as in:
The choice method in the numpy random module can effectively improve the efficiency of random extraction:
Note that you need to set replace to False, that is, the extracted elements can not be repeated, the default is True.
Additional knowledge:Python: random module's on-the-fly sampling functions: choices(), choices(), sample()
choice(seq): returns a random element from a sequence of seq's (which can be a list, tuple, or string).
choices(population, weights=None, *, cum_weights=None, k=1):
K random selections are made from the population, one element is selected each time (note that the same element will be selected several times), weights are relative weights, there are several elements in the population that should have corresponding weights, and cum_weights are cumulative weights, e.g., the relative weights [10, 5, 30. 5] is equivalent to cumulative weights [10, 15, 45, 50].
Internally, the relative weights are converted to cumulative weights before the selection is made, so providing cumulative weights saves work. Returns a list.
sample(population, k) samples from the population, k at a time, returning a k-long list.
You can use sample(range(10000000), k=60) like so
This above alternative based on () in Python is all I have to share with you, I hope it will give you a reference and I hope you will support me more.