title: Python line read size in bytes
body: <p>I'm working in linux.
  I would like to display the percentage of file parsed. That's why after reading a bit I decided that the most accurate way to do that would be get the total size (bytes) of the file i'm parsing then calculate the size (bytes) of each line after reading it.</p>
  
  <p>This is my dummy simplified code.</p>
  
  <pre><code>if __name__ == '__main__':
  
  read_bytes = 0
  total_file_size = os.path.getsize(myfile)
  
  with open(myfile, 'r') as input_file:
      for line in input_file:
          read_bytes += sys.getsizeof(line)
  
          print "do my stuff"
  
  print total_file_size
  print read_bytes
  </code></pre>
  
  <p>Output is: </p>
  
  <p>193794194</p>
  
  <p>203979278</p>
  
  <p>Obviously there's something count in line that's increasing total size.
  I've tried with:</p>
  
  <pre><code>read_bytes += sys.getsizeof(line) - sys.getsizeof('\n')
  </code></pre>
  
  <p>And output is:</p>
  
  <p>193794194</p>
  
  <p>193309190</p>
  
  <p>I must be missing something.</p>