9seconds/streams — pull request #3 by eykd (2014-11-21 05:21:32+00:00)
Title: Add (optional) caching interface to Stream.

By default, no caching is done, maintaining original behavior. The `max_cache` argument has been added to the constructor to enable caching behavior when an integer is specified.

A `.cache()` method has been added to create a cached copy of the present iterator. By default, every element is cached, but this can be controlled, again with a `max_cache` argument.

The cache uses a(n optionally sized) deque. There may be more efficient implementations possible--it would be worthwhile for future "iterations" to research how `itertools.tee()` is implemented.

Tests pass in Python 2.6, 2.7, and 3.4.