[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A Problem with Python's 'yield'
On Tue, 2003-05-27 at 14:09, Dan Sugalski wrote:
> At 11:15 AM -0400 5/27/03, Eric Kidd wrote:
> >We can shorten the code--and make it run in O(N) time--by adding a new
> >keyword to replace the "for v in ...: yield v" pattern:
> Color me confused here, but are you proposing to yield out of
> multiple levels of the call at once, or to yield multiple values at
> once, or to yield multiple values but store them up and parcel them
> out one per call?
I'm proposing to yield straight from the leaves of the tree to the
ultimate consumer, instead of yielding and re-yielding each value up the
tree one step at a time. Passing each leaf value up to the root adds an
extra O(log N) factor to the algorithm, which is just silly.
'yield_all' requires some implementation tricks--and it costs you an
extra level of indirection--but it can be done, even with a C back end.