CPython reverses a list through reverse_slice, whose whole body is while (lo < hi) with one pointer stepping up and the other stepping down. The random-access branch of C++ std::reverse is that loop written as first < last, and Java's Collections.reverse walks i up and j down to meet in the middle. Rotating without a scratch buffer is the same loop three times, reverse the front, reverse the back, reverse the whole, which is the path Java's Collections.rotate takes for lists it cannot index cheaply. Nothing is compared here, so what is left is the skeleton: two ends, a swap, and the crossing test that stops it.