I wrote the following programs to compare the speed of python with c/fortran. To get the time used by the programs I used the \"time\" command. All the programs compute the sq
Be aware that the calculation of r
does not depend on the loop variables, so an optimizing compiler may move the calculation out of the loop, and just run the empty loop for the requested number of times; or even remove that loop completely and only do the calculation of the square root.
A real smart optimizer may notice that you're not doing anything with the result, so the complete program may be optimized away without altering the output (i.e. nothing).