From http://stackoverflow.com/questions/845058/how-to-get-line-count-cheaply-in-python