Terry Reedy <tjre...@udel.edu> writes: > Python iterators can do lazy evaluation. All the builtin classes come > with a corresponding iterator. ...
I wouldn't say iterators do lazy evaluation in the Scheme or Haskell sense. Lazy evaluation imho means evaluation is deferred until you actually try to use the value, and when you use it, it is computed and kept around for later re-use (until it becomes gc-able). Python iterators simply generate one value at a time and leave retention of old values to be managed by the programmer. > There is nothing simulated about yield. Python mostly does what you > tell it to do. You just have to learn how to tell it to do what you > want. I'd be interested in seeing a clean implementation of that algorithm using python iterators. -- http://mail.python.org/mailman/listinfo/python-list