Help- Recursion v. Iter Speed comparison
actuary77 at elemental-systems.com
Wed Mar 2 07:28:08 CET 2005
Heiko Wundram wrote:
> On Wednesday 02 March 2005 06:03, actuary77 wrote:
>>It now makes sense if I write it, (simple):
>> if n == 0:
>> return 
>> return [n] + rec2(n-1)
> Or, if you're not interested in a recursive function to do this job (which
> should be way faster...):
> ... nl = range(1,n+1)
> ... nl.reverse()
> ... return nl
> [4, 3, 2, 1]
Recurse from 9999 time: 4.3059999942779541 seconds
Iter from 9999 time: 0.0099999904632568359 seconds
No comparison, why is recursion so slow?
Would using a generator be faster than recursion?
I really have complex list comprehension.
I am interating n times.
I have initial function: func(x)
I have initial seed value: _aseed
What would be the fastest way to do this?
More information about the Python-list