Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93757 > unrolled thread

Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2015-07-13 07:46 -0600
Last post2015-07-13 07:46 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Possibly Pythonic Tail Call Optimization (TCO/TRE) Ian Kelly <ian.g.kelly@gmail.com> - 2015-07-13 07:46 -0600

#93757 — Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-07-13 07:46 -0600
SubjectRe: Possibly Pythonic Tail Call Optimization (TCO/TRE)
Message-ID<mailman.465.1436795213.3674.python-list@python.org>
On Mon, Jul 13, 2015 at 6:34 AM, Chris Angelico <rosuav@gmail.com> wrote:
> On Mon, Jul 13, 2015 at 10:00 PM, Antoon Pardon
> <antoon.pardon@rece.vub.ac.be> wrote:
>> On 07/13/2015 01:28 PM, Chris Angelico wrote:
>>> Why is it worth writing your code recursively, only to have it be
>>> implemented iteratively?
>>
>> Because sometimes, it is easier to think about the problem recursively.
>
> Can you give me an example that (a) makes a lot more sense recursively
> than iteratively, and (b) involves just one tail call?

Why does (b) matter? If the function has more than one tail call, it
doesn't matter which one you hit -- either way it's a tail call and
the stack frame is no longer needed.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web