title: sort and get uniq lines of file in python
body: <p>i always use this commmand line to sort and get uniq lines only and it works as a charm even with large files (over 500,000 lines)</p>
  
  <pre><code>sort filename.txt | uniq | sponge filename.txt
  </code></pre>
  
  <p>shortest equivalent python code would be </p>
  
  <pre><code>f = open("filename.txt", "r")
  lines = [line for line in f]
  lines = lines.sort()
  lines = set(lines)
  </code></pre>
  
  <p>but of course this is not scalable because of memory constrains and writing scalable code in python would take time
  , so i wonder what is the shortest equivalent code (package) in python</p>