On Sun, Oct 10, 2010 at 2:55 PM, Zac Burns <zac256 at 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4