MCPcopy Index your code
hub / github.com/python/cpython / shuffle

Method shuffle

Lib/random.py:356–363  ·  view source on GitHub ↗

Shuffle list x in place, and return None.

(self, x)

Source from the content-addressed store, hash-verified

354 return seq[self._randbelow(len(seq))]
355
356 def shuffle(self, x):
357 """Shuffle list x in place, and return None."""
358
359 randbelow = self._randbelow
360 for i in reversed(range(1, len(x))):
361 # pick an element in x[:i+1] with which to exchange x[i]
362 j = randbelow(i + 1)
363 x[i], x[j] = x[j], x[i]
364
365 def sample(self, population, k, *, counts=None):
366 """Chooses k unique random elements from a population sequence.

Callers 15

test_expanduser_pwd2Method · 0.80
testStressfullyMethod · 0.80
test_decoratedMethod · 0.80
test_reverseMethod · 0.80
test_basicMethod · 0.80
prepare_dataMethod · 0.80
test_intsMethod · 0.80
test_floatsMethod · 0.80
test_decimalsMethod · 0.80

Calls 1

randbelowFunction · 0.85

Tested by 15

test_expanduser_pwd2Method · 0.64
testStressfullyMethod · 0.64
test_decoratedMethod · 0.64
test_reverseMethod · 0.64
test_basicMethod · 0.64
prepare_dataMethod · 0.64
test_intsMethod · 0.64
test_floatsMethod · 0.64
test_decimalsMethod · 0.64