recursive function

Brandon K prince_amir86 at yahoo.com
Fri Oct 7 07:34:31 EDT 2005


Is there no way to implement your idea in a classical loop? Usually the 
syntax is cleaner, and there is no limit (except the limit of the range 
function in certain cases).  For example what would be wrong with.

def foo(j):
     while j < n:
	j+=1
     return j

I don't know much about the internals of python, but to me it seems like 
if you're going to be doing this on the level of 1000s of iterations, 
there might be some overhead to using recursion (i.e. function calls) 
that a loop wouldn't have (but that's just a guess).

> Hello,
> 
> In a recursive function like the following :
> 
> 
> def foo( j ) :
>  j += 1
>  while j < n : j = foo( j )
>  return j
> 
> 
> in found that the recursivity is limited (1000 iterations). Then, I have 
> two questions :
> - why this mecanism has been implemented ?
> - it is possible to increase or remove (and how) the number of iterations ?
> 
> Regards,
> Mathieu


----== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups ==----
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
----== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==----





More information about the Python-list mailing list