[Python-ideas] Idea: Compressing the stack on the fly

Haoyi Li haoyi.sg at gmail.com
Mon May 27 06:18:37 CEST 2013


I don't think setrecursionlimit is the answer here. It's like answering
"hey maybe we can save some cash here" with "why not just make more money?".

The fact that python's conventions encourages using iterators and explicit
state machines instead of tail-recursion and tail-calls is worth something,
but simply saying "it slows down all computation for rare benefit" and
"does not scale well" is rather hand wavy. We already are not going to
process billion character strings with iteration in python (python loops
are sloooow). There are some (not-factorial) algorithms which are more
naturally expressed recursively than iteratively.

Saying recursion is slower and more memory intensive than iteration (true),
and thus we shouldn't think about making recursion less slow or less memory
intensive doesn't really make much sense to me.

This is an extremely novel idea, which begs the question: has it been done
before? In any other language/runtime? And how did it turn out? A cursory
googling doesn't get me anything, and my gut says this is more PhD thesis
than quick hack.

-Haoyi


On Sun, May 26, 2013 at 9:30 PM, alex23 <wuwei23 at gmail.com> wrote:

> On May 27, 6:23 am, Ram Rachum <r... at rachum.com> wrote:
> > So in those cases where you have to use recursion, it would be nice if
> the
> > stack could be compressed so the program could put 1000x many frames on
> the
> > stack and will be less likely to crash.
>
> http://docs.python.org/2/library/sys.html#sys.setrecursionlimit
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130527/e2e1eadb/attachment-0001.html>


More information about the Python-ideas mailing list