On Wed, Aug 28, 2002 at 10:27:30AM -0400, Guido van Rossum wrote: > > Ahh... re-iterability again... > > > > This is a good example of a function that *fails silently* for non > > re-iterable arguments. > > This failure is hardly silent IMO: the results are totally bogus, > which is a pretty good clue that something's wrong. Sure, at the interactive prompt or very shallow code it is obvious. Exceptions are noisy. Anything else is silent. > > Slurping the tail into a list loses the lazy efficiency of this function. > > One of the ways I've used this function is to scan combinations until a > > condition is satisfied. The iteration is always terminated before reaching > > the end. Reading ahead may waste computation and memory. > > I don't understand. The Cartesian product calculation has to iterate > over the second argument many times (unless you have it iterate over > the first argument many times). So a lazy argument won't work. Am I > missing something? Even if all the arguments are re-iterable containers the recursive call produces a lazy generator object - the cartesian product of the tail. I don't want to read it eagerly into a list. 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