is there built-in method to determine the number of lines in a file?

i tried file.readlines.length but it is very slow (dealing with files  
 > 1 million lines)

thanks,
DAN