Subject: 250k in coverage | No Exam necessary

From: Your Term-Life Policy <[email-masked]>
Date: Wed, 12 Nov 2014 10:28:23 -0800

Good Afternoon Atompub-archive,

Of all the things you can protect, nothing is more important to protect than your own life. Life is full of unexpected situations and events, so it pays to be prepared for anything.

Package Currently Available:
-------------------------------
[$250k In Coverage $15/month] | [No Medical exam necessary]
--> http://www.thekrogshop.com/shifts/swizzles/COAOYP1qfP/wrests/quartered/availing.rb

Life coverage helps provide you peace of mind and can provide your family with financial-stability and security when it matters most.

Thank You.

This is from LIL Life Agency -1107 Valeria Drive-Marion_TX_78124-

-To easily-end updates from our publications Write or you can navigate to this URL http://www.thekrogshop.com/reptiles/inserters/warblers/grocery/elitisms/omicrons.rhtml -

\

Python has a maximum recursion depth, but no maximum iteration depth. Why is recursion restricted? Wouldn't it be more natural to treat recursion like iteration, and not restrict the number of recursive calls?

Let me just say that the source of this issue came from trying to implement a stream (see this question for more details about streams). For example, say we want to write a stream to produce the natural numbers:

def stream_accum(s, n): # force the stream to a list of length n
    def loop(s, acc):
        if len(acc) == n:
            return acc
        hd, tl = s()
        return loop(tl, acc + [hd])
    return loop(s, [])

def nats():
    def loop(n):
        return n, lambda: loop(n+1)
    return loop(1)
The recursive definition of streams is quite appealing. However, I guess the better/more pythonic approach would be to use generators.

python recursion stack
share|improve this question
edited 46 mins ago

asked 1 hour ago

gjdanis
4068
  	 	
The "appealing" recursive solution has a number of unappealing aspects. First, it has O(n**2) behavior because you are continually building new lists to extend them. Second, it's overly complex given that you can simply iterate to produce natural numbers. This is an example of writing Python as if it were Scheme or Haskell. Different languages are good at different things. Use iteration.   Ned Batchelder 28 mins ago
add a comment
3 Answers
activeoldestvotes
up vote
3
down vote
accepted
There are actually a few issues here.

First, as NPE's answer nicely explains, Python doesn't eliminate tail calls, so many functions that would allow unlimited recursion in, say, Scheme are limited in Python.

Second, as again as explained by NPE, calls that can't be eliminated take up space on the call stack. And, even in languages that do TCE, there are plenty of recursive functions that can't be treated like iteration. (Consider the naive Fibonacci function that recursively calls itself twice.)

But why is the call stack a finite resource in the first place? Python stack frames can at least in principle be implemented on the heap and linked together (see Stackless for an existence proof of that principle), and in a 64-bit memory space, there's room for a whole lot more than 1000 stack frames. (In fact, even the C stack on almost any modern platform can hold a whole lot more than 1000 recursive Python interpreter calls.)

Part of the reason is historical: the stock Python interpreter uses the fixed C stack to call itself recursively whenever you make a recursive call, and it was originally designed for 32-bit (and even 24- or 20-bit) platforms where that C stack is pretty small.

But that could have been changed, and Python 3.0 would have been a perfect place to change it. So, why didn't they? Because they made a conscious language design decision. In Pythonic code, recursion is generally very shallow (e.g., code like os.walk that traverses shallow tree structures); if your function hits a depth of anywhere near 1000, it's more likely to be a bug than to be intentional. So, the limit stays. Of course this is a bit circularif they removed the limit (and, especially, if they eliminated tail calls), deeper recursion would become more idiomatic. But that's kind of the pointGuido doesn't want a language where deep recursion is idiomatic. (And most of the Python community agrees.)

share|improve this answer
edited 58 mins ago

answered 1 hour ago

abarnert
112k379154
  	 	
Very informed answer...thank you!   gjdanis 49 mins ago
add a comment

up vote
7
down vote
This is not unique to Python, and has to do with each call taking space on the call stack, and the size of the stack being limited.

Iteration alone does not consume stack space and is therefore not subject to this limit.

Not every recursive call needs to consume stack space. For example, some languages can automatically transform tail recursion into iteration. However, CPython chooses not do that (Does Python optimize tail recursion?).

You can increase the maximum depth of the Python call stack by calling sys.setrecursionlimit.

Uh N0
Mock Pride
Uh N0
Mock Pride
Uh N0
Where did you find this?

Did you make it?
I'm talking about tier lists in general. But this particular one was straight off the smash wiki.

Interesting, well it's nice to see some of the older baddies getting better ranks on the list. Though you talk about about Lil Mac over use. I honestly see Roselina every other match. QQ
I only mentioned Little Mac because it seemed like he was getting a little bit more notoriety since the game came out since Rosalina idn't have a garbage article published about him flooding the game.

Rosalina is by far over used now I'm starting to see Lucina a lot too QQ
I'm pretty sure that at least a lot of it has to do with people wanting to play the new characters. In a few months I would expect that For Glory mode will be filled with almost every character relatively evenly...as long as they're around the top 15-20