#!/usr/local/bin/python2 l = range(20) for i in xrange(500000): t = iter(l) t2 = (n for n in t) r = next(t2) for n in t2: n print r