title: Efficient and fast Python While loop while using sleep()
body: <p>I am attempting to communicate with a device over serial using Pyserial.  As commands need to be continually sent, they have to be placed in a while loop in Python.</p>
  
  <p>I am currently using this code, and have taken a look at <a href="https://stackoverflow.com/questions/9349588/python-process-takes-100-cpu">python process  takes 100% CPU</a>:</p>
  
  <pre><code>while True:
      #do some serial sending here
      time.sleep(0.2)
  </code></pre>
  
  <p>This code works.  However, the sending speed is slow.  I tried to make it faster by decreasing the <code>sleep</code> interval, but it seems to load the CPU a bit too much.</p>
  
  <p>In short, is there a any way to effectively iterate over a while loop forever, while still maintaining a low consumption of CPU resources?</p>