Skip to content

Instantly share code, notes, and snippets.

@cpdean
Created June 14, 2013 20:24
Show Gist options
  • Save cpdean/5784980 to your computer and use it in GitHub Desktop.
Save cpdean/5784980 to your computer and use it in GitHub Desktop.
demonstrates a segfault on python 2.7.3 and python 3.2.3
import itertools, timeit
import sys
if sys.version_info < (3,):
range = xrange
a = (i for i in range(11**7)); b,c = itertools.tee(a)
print(timeit.timeit(lambda : sum(b), number=1))
# this line segfaults:
a = (i for i in range(11**7)); b,c = itertools.tee(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment