Shuffling's way harder than you'd think to do right - the gold standard for it requires enough bits of RNG state to hold all possible mutations in order to hit all permutations and for all but small arrays (of <= 34 entries), they can't even use what they use for
- If they use xorshift1024* (fails a couple major statistical tests), they can shuffle arrays up to 170 entries and still potentially hit every permutation.
- If they use the WELL44497a (fairly slow and heavy), they can shuffle arrays up to 4199 entries and still potentially hit every permutation.
- About anything else would require a hardware RNG.
And yes, I'm saying that Python's default is actually very bad.
Random choice I'm not a fan of - it'd be better if we just got a
Math.randomInt(min, max) instead that was effectively
min + Math.floor(Math.random() * (max - min)), but something engines could optimize for and knock out the bias in. Then, you could do
array[Math.randomInt(0, array.length)] and call it a day. (Also, in my experience, random integers are way more useful in contexts outside of array handling.)