Python's itertools module provides a lots of goodies with respect to processing an iterable/iterator by use of generators. For example,
permutations(range(3)) --> 012 021 102 120 201 210
combinations('ABCD', 2) --> AB AC AD BC BD CD
[list(g) for k, g in groupby('AAAABBBCCD')] --> AAAA BBB CC D
What are the equivalent in Ruby?
By equivalent, I mean fast and memory efficient (Python's itertools module is written in C).