On Sun, Oct 10, 2010 at 2:55 PM, Zac Burns <zac...@gmail.com> wrote: > This could be generalized and placed into itertools if we create a function > (say, apply for lack of a better name at the moment) that takes in an > iterable and creates new iterables that yield each from the original > (avoiding the need for a list) holding only one in memory. Then you could > pass the whatever function you wanted to run the iterables over an get the > result back in a tuple.
Time machine partially beat you to this one. Look at the docs on itertools.tee tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n Can be used like so: >>> it = iter(range(100)) >>> it1, it2 = itertools.tee(it) >>> max(it1) 99 >>> min(it2) 0 This doesn't quite have the memory characteristics you describe, but it's about as good as you can expect in a single threaded environment. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com