> But I don't understand how it would be quite messy to take advantage > of this in tee(), either: simply, tee() would start with the equivalent of > it = iter(it) > try: return it, copy.copy(it) > except TypeError:pass > and proceed just like now if this shortcut hasn't worked -- that's all. Right, that's what the tee() at the end of my code did, except it checked for __copy__ explicitly, since I assume that only iterators whose author has thought about copyability should be assumed copyable; this means that the default copy stategy for class instances (classic and new-style) as suspect. tee is more and less powerful than copy; it is more powerful because it works for any iterator, but less so because you can't continue using the underlying iterator (any calls to its next() method will be lost for both tee'ed copies). --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