simple recursion help

Alex Martelli aleaxit at yahoo.com
Sun Oct 24 09:51:14 EDT 2004


Michael J. Fromberger <Michael.J.Fromberger at Clothing.Dartmouth.EDU>
wrote:
   ...
> > In 2.4 one can do a bit better for the yield, with
> > 
> >         yield ''.join(alph[i] for i in reversed(ixs))
> > 
> > [generator expression vs list comprehension, and reversed built-in vs
> > reversal by slicing].
> 
> Yes, I'm aware of both of those improvements, but since I do not yet 
> have Python 2.4, I did not use any of its new features in my solution.

Everybody's strongly urged to download and try 2.4 beta 1.  We think
it's quite solid and speedy, but unless users validate that on their
huge variety of platforms and programs, how can we be _sure_?

> In any case, thank you for the helpful comments on both sides of the 2.4
> divide.

You're welcome!  Also note that on the other branch of this thread a
non-recursive, list based solution was posted that's about an order of
magnitude faster for short alph and small values of k (not applicable to
the general problem of yielding an unbounded sequence of strings, but
useful for the original problem where the sequence of strings was
specified to be reasonably small).


Alex



More information about the Python-list mailing list