-----Original Message----- From: Westley Martínez [mailto:email@example.com] Sent: Wednesday, September 11, 2013 9:03 PM To: 'Ram Rachum'; 'firstname.lastname@example.org' Cc: 'Ram Rachum' Subject: RE: [Python-ideas] Idea: Compressing the stack on the fly
-----Original Message----- From: Python-ideas [mailto:python-ideas- email@example.com] On Behalf Of Ram Rachum Sent: Sunday, May 26, 2013 5:00 AM To: firstname.lastname@example.org Cc: Ram Rachum Subject: [Python-ideas] Idea: Compressing the stack on the fly
So what I'm suggesting is an algorithm to compress that stack on the fly. An algorithm that would detect regularities in the stack and instead of saving each individual frame, save just the pattern. Then, there wouldn't be any problem with showing informative stack trace: Despite not storing every individual frame, each individual frame could still be accessed, similarly to how `xrange` allow access to each individual member without having to store each of them.
Then, the stack could store a lot more items, and tasks that currently require recursion (like pickling using the standard library) will be able to handle much deeper recursions.
What do you think?
I think this is an interesting idea. It sounds possible, but the question is whether or not it can be efficiently done with Python.
I'd heed Guido's advice in first implementing this. It could probably be done effectively with a compiled language like C, but I'd imagine it'd be too difficult for Python.
The other question is usability. What would this actually be used for. I'm not a fan of recursion. I think anything that uses recursion could be restructured into something simpler. A lot of people find recursion to be elegant. For me it just hurts my brain.