Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed8.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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'overflow': 0.07; 'cc:addr :python-list': 0.09; 'stack': 0.13; '*before*': 0.16; 'claim,': 0.16; 'dropping': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'thread.': 0.16; 'unneeded': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; "python's": 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'message-id:@mail.gmail.com': 0.27; '14,': 0.27; 'converting': 0.27; 'function': 0.28; 'away.': 0.29; 'tail': 0.29; 'subject:/': 0.30; 'call.': 0.30; 'optimize': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'means': 0.39; "didn't": 0.39; 'still': 0.40; 'space': 0.40; 'claim': 0.61; 'making': 0.62; 'levels': 0.70; 'jul': 0.72; 'actually,': 0.84; 'chrisa': 0.84; 'claim.': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=RoivOu5TRz2jCb13I9PPXYnhbrEa3PI6H6+rahVQ5Lc=; b=n2Jvxve3gnn60eYXDdmlZXMy6Ozb5Pyjx/PT0kPwbDm+DEc0CSCx3uEOhLrZ5hwUlT qDCUrNmQqUsFubQ9lzAOwfQpKVazbPhA2gYQ5wdEcqZAoxOYNlznuI3Is+3Fsfi01FtD Hwc918VbmK6mcsuxVjEwGWvHifvdsRRBp9xcwJbvP+NO6rh2UIZsu+wh1RKVOHgpAbEI 70McNEeqQQD8EXMBRdF2yWA8ZXNA4P7AP50oc20xoSl1x/qWLP1qiUH+Dc/5lCZLZ1r7 16sbb+v6b7Z47V1vo9Y2HmzreJGC5dlInZVTvYqqvHLlpg/jtIILxJ0Xn7j/ioOCBSyc cr+g== MIME-Version: 1.0 X-Received: by 10.107.9.142 with SMTP id 14mr27568866ioj.142.1436873635633; Tue, 14 Jul 2015 04:33:55 -0700 (PDT) In-Reply-To: <87bnffnvn2.fsf@elektro.pacujo.net> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnffnvn2.fsf@elektro.pacujo.net> Date: Tue, 14 Jul 2015 21:33:55 +1000 Subject: Re: Possibly Pythonic Tail Call Optimization (TCO/TRE) From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436873643 news.xs4all.nl 2919 [2001:888:2000:d::a6]:43019 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 4207 X-Received-Body-CRC: 4085635768 Xref: csiph.com comp.lang.python:93800 On Tue, Jul 14, 2015 at 3:41 PM, Marko Rauhamaa wrote: > Tail-call optimization has nothing to do with converting algorithms into > iterations. It's a prosaic trick of dropping an unneeded stack frame > before making a function call. > >> The claim that TCO means you don't need stack space for all those >> levels of recursion doesn't work if you still need stack space for all >> those levels of recursion *before* you get to the tail call. > > Nobody is making that claim. Actually, that claim was made - that Python's stack would overflow if you didn't optimize tail calls away. I don't feel like digging up through the history to find out who first made the claim, but it was made in this thread. ChrisA