Created
October 24, 2014 20:36
-
-
Save danvk/6ac21423945e5067f9f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
si = sys.stdin | |
CHUNK_SIZE = 100000 | |
n = 0 | |
while True: | |
b = si.read(CHUNK_SIZE) | |
if not b: | |
break | |
n += b.count('\n') | |
if len(b) < CHUNK_SIZE: | |
break | |
print n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is about as fast as the C version of
wc -l
: