title: How to I read several lines in a file faster using python?
body: <p>As of now I use the following python code:</p>
  
  <pre><code>file = open(filePath, "r")
  lines=file.readlines()
  file.close()
  </code></pre>
  
  <p>Say my file has several lines (10,000 or more), then my program becomes slow if I do this for more than one file. Is there a way to speed this up in Python? Reading various links I understand that readlines stores the lines of file in memory thats why the code gets slow.</p>
  
  <p>I have tried the following code as well and the time gain I got is 17%.</p>
  
  <pre><code>lines=[line for line in open(filePath,"r")]
  </code></pre>
  
  <p>Is there any other module in python2.4 (which I might have missed).
  Thanks,
  Sandhya</p>