title: Execute statement every N iterations in Python
body: <p>I have a very long loop, and I would like to check the status every N iterations, in my specific case I have a loop of 10 million elements and I want to print a short report every millionth iteration.</p>
  
  <p>So, currently I am doing just (n is the iteration counter):</p>
  
  <pre><code>if (n % 1000000==0):
      print('Progress report...')
  </code></pre>
  
  <p>but I am worried I am slowing down the process by computing the modulus at each iteration, as one iteration lasts just few milliseconds.</p>
  
  <p>Is there a better way to do this? Or shouldn't I worry at all about the modulus operation?</p>