Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.pionier.net.pl!feed.xsnews.nl!border03.ams.xsnews.nl!feeder03.ams.xsnews.nl!abp002.ams.xsnews.nl!frontend-F10-17.ams.news.kpn.nl From: Cecil Westerhof Newsgroups: comp.lang.python Subject: Re: Throw the cat among the pigeons Organization: Decebal Computing References: <87h9rvm576.fsf@Equus.decebal.nl> <871tixlmp6.fsf@Equus.decebal.nl> <750db03b-e393-43ff-9ccf-5cc050af7324@googlegroups.com> <87zj5jf15q.fsf@Equus.decebal.nl> X-Face: "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR,v+Pti8=Vi/Z"g^?b"E X-Homepage: http://www.decebal.nl/ Date: Tue, 05 May 2015 23:12:49 +0200 Message-ID: <87mw1ig23y.fsf@Equus.decebal.nl> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:lwarNuhZbP8dcatWcyZ18vp6Ugg= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Lines: 26 NNTP-Posting-Host: 81.207.62.244 X-Trace: 1430860488 news.kpn.nl 1234 81.207.62.244@kpn/81.207.62.244:38801 Xref: csiph.com comp.lang.python:90003 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 ‘tail recursive’ 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, so I needed to program the tail recursion myself. Tail recursion would do under the hood what I did there manually. > while the 'iterative version' > was an iterative for loop version. In this thread, you just posted > timings without code. I will not believe your claim until I see one > file that I can run myself with an actual tail recursive function, > as above, that beats the equivalent while or for loop version. https://github.com/CecilWesterhof/PythonLibrary/blob/master/mathDecebal.py -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof