title: How is split('\n') method in Python implemented?
body: <p>This is a theoretical question to be able to understand a difference between Java and Python.
  To read the content of a file into an array in Java, you need to know the number of lines, in order to define the size of the array when you declare it. And because you cannot know it in advance, you need to apply some tricks to overcome that problem.</p>
  
  <p>In Python though, lists can be of any size, so reading the content of a file into a list can be either done as:</p>
  
  <pre><code>lines = open('filename').read().split('\n')
  </code></pre>
  
  <p>or </p>
  
  <pre><code>lines = open('filename').readlines()
  </code></pre>
  
  <p>How does split('\n') work in this occasion? Is Python implementation performing some kind of tricks underneath as well (like doubling the size of an array when needed, etc.)? </p>
  
  <p>Any information in shedding light into this would be much appreciated.</p>