On 6/15/2012 3:04 PM, Paul Rubin wrote:
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.

Ok, I see the difference. You are talking about something like a memoized __getitem__ that computes and store values as needed.

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.

I already wrote "The problem being discussed may be a case where [linked lists] are useful and make it easier to save space" -- because, from what I understood, a moving buffer of temporarily saved buffers is needed.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to