In computer programs, an important form of control flow is the loop which causes a block of code to be executed more than once.
[2] It was observed that more computations are performed per unit time when an inner for loop is involved than otherwise.
This implies, given the same number of computations to perform, the one with an inner for loop will finish faster than the one without it.
This technique of loop optimization was observed across several programming languages and compilers or interpreters.
Python Nested For Loop From Techgeekbuz