erikrose/more-itertools — pull request #27 by nvie (2013-06-18 12:38:01+00:00)
Title: Add the `sift()` itertool

Sift creates two lazy subiterators that together consume the input.

>>> even, odd = sift(xrange(10), key=lambda x: x % 2 == 0)
>>> list(even)
[0, 2, 4, 6, 8]
>>> list(odd)
[1, 3, 5, 7, 9]

It's more efficient than looping over the input twice with two inverse filters.