Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15110 > unrolled thread

Fast recursive generators?

Started byMichael McGlothlin <michaelm@plumbersstock.com>
First post2011-10-28 12:10 -0600
Last post2011-10-28 12:10 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Fast recursive generators? Michael McGlothlin <michaelm@plumbersstock.com> - 2011-10-28 12:10 -0600

#15110 — Fast recursive generators?

FromMichael McGlothlin <michaelm@plumbersstock.com>
Date2011-10-28 12:10 -0600
SubjectFast recursive generators?
Message-ID<mailman.2288.1319825439.27778.python-list@python.org>
I'm trying to generate a list of values where each value is dependent
on the previous value in the list and this bit of code needs to be
repeatedly so I'd like it to be fast. It doesn't seem that
comprehensions will work as each pass needs to take the result of the
previous pass as it's argument. map() doesn't seem likely. filter() or
reduce() seem workable but not very clean. Is there a good way to do
this? About the best I can get is this:

l = [ func ( start ) ]
f = lambda a: func ( l[-1] ) or a
filter ( f, range ( big_number, -1, -1 ) )


I guess I'm looking for something more like:

l = do ( lambda a: func ( a ), big_number, start )


Thanks,
Michael McGlothlin

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web