> > I thought we already established before that attempting to guess wihch > > parts of a generator function to copy and which parts to share is > > hopeless. generator-made iterators won't be __copy__-able, period. > > > I think this is the weakness of this cloning business, because it > > either makes generators second-class iterators, or it makes cloning a > > precarious thing to attempt when generators are used. (You can make a > > non-cloneable iterator cloneable by wrapping it into something that > > buffers just those items that are still reacheable by clones, but this > > can still require arbitrary amounts of buffer space. > > However, the buffering can be done in a way that uses only as much > buffer space as is truly needed. Just maintain the buffer as a > singly linked list in which new elements are inserted at the *tail* > of the list. Then whenever the head becomes unreachable > (e.g. because no iterators refer to it), it will be garbage > collected. Correct. For this reason, Raymond will make a leak-proof version of his tee() function part of itertools. --Guido van Rossum (home page: http://www.python.org/~guido/)
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