title: Quick way to remove largest values in big list in Python?
body: <p>Very quickly: I have a file full of numbers. I use this function to load this file into a list:</p>
  
  <pre><code>with open("log.txt") as log:
      avg = log.read().split(",")
  avg = [int(i) for i in avg]
  print("list constructed.")
  </code></pre>
  
  <p>Now I want to remove all values in the list which are larger than a certain number. I set up this loop:</p>
  
  <pre><code>while (max(avg)) &gt; 200:
      avg.remove(max(avg))
  </code></pre>
  
  <p>Unfortunately, this takes a ridiculous amount of time per iteration. Almost five seconds. I should mention that the file <code>log.txt</code> and by extension the list <code>avg</code> has upwards of 101 million entries which makes five seconds per iteration an unbearable speed. Is there any way to do this more elegantly and most importantly, more quickly? I'm pretty new to programming altogether, so I'd appreciate some help on this, thanks!</p>