Why is shuffling list(range(n)) slower than shuffling [0]*n?
问题 Using random.shuffle , I noticed that shuffling list(range(n)) takes about 25% more time than shuffling [0] * n . Here are times for sizes n from 1 million to 2 million: Why is shuffling list(range(n)) slower? Unlike for sorting a list (which needs to look at the objects) or copying a list (which increases reference counters inside the objects), the objects shouldn't matter here. This should just rearrange pointers inside the list. I also tried numpy.random.shuffle , where shuffling list