On Wed, Aug 28, 2002 at 03:41:00PM -0400, Guido van Rossum wrote: > > > Or you might use Oren's favorite rule of thumb and listify it when iter(x) > > > is iter(x) (or iter(x) is x). > > > > I'm a bit annoyed by the idea that `iter(x)' might require some computation > > for producing an iterator, and that we immediately throw away the result. > > Granted that `__iter__(self): return self' is efficient when an object is > > an iterator, but nowhere it is said that `__iter__' has to be efficient > > when the object is a container, and it does not shock me that some complex > > containers require time to produce their iterator. I much prefer limiting > > the use of `__iter__' for when one intends to use the iterator... > > Yes, that's why I prefer to just make a list() copy. Oh, come on you two... stop beating up the poor strawman. The reiter() function doesn't make a single redundant call to __iter__. It's just like iter() but ensures in passing that the result is really a fresh iterator. Oren
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