Skip to content

Instantly share code, notes, and snippets.

@danvk
Created October 24, 2014 20:36
Show Gist options
  • Select an option

  • Save danvk/6ac21423945e5067f9f4 to your computer and use it in GitHub Desktop.

Select an option

Save danvk/6ac21423945e5067f9f4 to your computer and use it in GitHub Desktop.
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
@ryan-williams
Copy link
Copy Markdown

very cool. let's speed out the ol' streaming version then! feel free to file issues there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment