X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 195.154.70.45 Path: csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'cpython': 0.05; 'compiler': 0.07; 'method.': 0.07; 'cest': 0.09; 'function,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rejected': 0.09; 'python': 0.11; 'jan': 0.12; 'wrote': 0.14; 'combinations': 0.16; 'hardware.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'settings,': 0.16; 'specific,': 0.16; 'thread,': 0.16; 'wrote:': 0.18; 'slightly': 0.19; 'version.': 0.19; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'equivalent': 0.26; 'values': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'relative': 0.30; 'too.': 0.31; 'url:wiki': 0.31; 'post.': 0.31; 'produces': 0.31; 'url:wikipedia': 0.31; 'subject:the': 0.34; 'but': 0.35; 'version': 0.36; 'functions.': 0.36; 'url:org': 0.36; 'operating': 0.37; 'system,': 0.38; 'version,': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'removing': 0.60; 'skip:* 10': 0.61; 'first': 0.61; 'refer': 0.63; 'more': 0.64; 'different': 0.65; 'between': 0.67; 'believe': 0.68; 'yes': 0.68; 'percent': 0.68; '2015': 0.84; 'iterative': 0.84; 'received:fios.verizon.net': 0.84; 'recursion,': 0.84; 'timings': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Throw the cat among the pigeons Date: Tue, 05 May 2015 19:22:55 -0400 References: <87h9rvm576.fsf@Equus.decebal.nl> <871tixlmp6.fsf@Equus.decebal.nl> <750db03b-e393-43ff-9ccf-5cc050af7324@googlegroups.com> <87zj5jf15q.fsf@Equus.decebal.nl> <87mw1ig23y.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: <87mw1ig23y.fsf@Equus.decebal.nl> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430868187 news.xs4all.nl 2942 [2001:888:2000:d::a6]:38288 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90010 On 5/5/2015 5:12 PM, Cecil Westerhof wrote: > Op Tuesday 5 May 2015 22:46 CEST schreef Terry Reedy: > >>> Well, I did not write many tail recursive functions. But what >>> surprised me was that for large values the =E2=80=98tail recursive=E2= =80=99 version >>> was more efficient as the iterative version. >> >> In your first thread, what you mislabelled 'tail recursive version' >> was an iterative while loop version > > That is because Python has no tail recursion, Yes is does. Please stop using 'tail recursion' to refer to the absence=20 of recursion or the process of removing recursion. I wrote a tail=20 recursive function, and I believe you did too. What Python does not have is automatic tail call optimization, or=20 specifically, tail recursion *elimination*. Both possibilities, the=20 general and specific, have been considered and rejected for excellent=20 reasons. I hinted at some of them in my post. See https://en.wikipedia.org/wiki/Tail_call for 'tail recursion' and 'tail call elimination' What I believe you showed is that a while loop can be faster than a more = or less equivalent for loop that produces the same result by a slightly=20 different method. That is not surprising. Relative timings for CPython = vary a few percent between different combinations of Python version, C=20 compiler and settings, operating system, and cpu and other hardware. --=20 Terry Jan Reedy