Possibly Pythonic Tail Call Optimization (TCO/TRE)

Ian Kelly ian.g.kelly at gmail.com
Tue Jul 14 10:34:11 CEST 2015

On Tue, Jul 14, 2015 at 1:26 AM, Antoon Pardon
<antoon.pardon at rece.vub.ac.be> wrote:
> On 07/14/2015 05:20 AM, Steven D'Aprano wrote:
>> On Tue, 14 Jul 2015 12:05 am, Chris Angelico wrote:
>>> If you want to make an assertion that iterative
>>> code requires equivalent warping to tail-recursive code, I want to see
>>> an example of it. Is that difficult?
>> Of course it is. If it wasn't difficult, people would post examples instead
>> of getting all defensive about being asked for examples.
> Shrug! I have seen this game played before. It has been played since before
> python had an if-expression. It always goes as follows. Some one mentions
> a feature python doesn't has and that could be useful. The python status-quo
> people will argue that it is unnecessary. Any example that will be given
> to illustrate the advantage will be nit picked appart for any possible flaw,
> while mostly ignoring the flaws in the status quo.
> Before python had an if-expression, examples were asked too and they
> convinced
> noone. It wasn't until a core developer was bitten by an elusive bug, caused
> by using the then advised "and or" combination, that python got an
> if-expression
> and that an if-expression was considered useful by the python community
> in general.
> I expect any example given, to be used as a contest by those reading,
> for finding
> the least warped alternative and then using that to dismiss the example.
> So I really don't feel compelled to search through my code in the hope
> of finding
> an example that would persuade someone.

And yet, Python somehow manages to gain new features with each release.

The reason why most proposals get rejected is because most proposals
are bad. If every idea that came along just got accepted, we'd have a
disastrous hodge-podge of a language.

In the case of TCO, Guido rejected the feature six years ago and
hasn't shown any sign of changing his mind. He considered the
arguments for it, and he decided that for Python, the benefits don't
outweigh the drawbacks. Maybe his mind could still be changed, but
it's going to take somebody to make a very convincing case for the
feature, and if you're not even willing to put forth some examples
then you don't have a case at all.

More information about the Python-list mailing list