Something like this may be fast enough:

>>> from itertools import izip
>>> xpartition = lambda seq, n=2: izip(*(iter(seq),) * n)
>>> xprimes = (x for x in xrange(2, 100) if all(x % i for i in xrange(2, x)))
>>> list(xpartition(xprimes))
[(2, 3), (5, 7), (11, 13), (17, 19), (23, 29), (31, 37), (41, 43),
(47, 53), (59, 61), (67, 71), (73, 79), (83, 89)]

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to