On 19 January 2014 12:27, spir firstname.lastname@example.org wrote:
On 01/19/2014 12:54 PM, Joao S. O. Bueno wrote:
On 19 January 2014 08:52, Mark Lawrence email@example.com wrote:
On 19/01/2014 07:39, firstname.lastname@example.org wrote:
I propose tail-call optimization to be added into CPython.
Then implement it so everybody else can use it.
On a second though, it actually could be done, at the VM level. I am not a proponent, but after my second though I am from "-1" to "+0".
I believe that anytime one have the sequence:
20 CALL_FUNCTION 1 23 RETURN_VALUE
in byte code, the current stack frame could be discarded prior to making the function call. Looking from 10000 meters, it feels like it would not impact any other aspect of the language but for enabling automatically tail recursion calls.
You also need to adjust frame size, possibly even its structure (dunno, depends on implementation details of python's "calling convention" so to say), to get a right space (and disposition) for the callee's input variables.
Not in this suggestion - I did not propose re-using the frame, as seens to be the case around the calls, just because of that: these frames in Python seen to be tied to the code object within it. My suggestion is simply to discard the current frame before building the frame for the call. (Maybe adding some logging information on this next frame so that the stack trace could be complete)
Python-ideas mailing list Pythonemail@example.com https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/