The Cython compiler expands `for i in range(n)`, and a few variant constructs, to a C `for` loop when `i` and `n` are properly typed. Check the generated C code to see this at work (it has the input Cython code in comments).