Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'anyway.': 0.04; 'debug': 0.04; 'semantic': 0.07; 'cc:addr:python-list': 0.09; 'loop.': 0.09; 'worse': 0.09; 'anyway': 0.11; 'wed,': 0.15; '--debug': 0.16; 'distinct': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'something.': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'version.': 0.18; '>>>': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'assumes': 0.22; 'disable': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; '14,': 0.27; 'record': 0.29; 'does,': 0.29; 'equivalent.': 0.29; 'tail': 0.29; 'program,': 0.29; 'there.': 0.30; 'subject:/': 0.30; '15,': 0.30; 'certainly': 0.30; 'compared': 0.30; 'doubt': 0.33; 'optimize': 0.33; 'traceback': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'clear': 0.35; 'instance': 0.35; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'no,': 0.38; 'rather': 0.39; 'called': 0.40; 'behavior': 0.61; 'default': 0.61; 'per': 0.62; 'making': 0.62; 'lose': 0.63; '>>>>>': 0.66; 'records': 0.70; 'jul': 0.72; 'chrisa': 0.84; 'iterative': 0.84; 'loose': 0.84; 'pardon': 0.84; 'recursion,': 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=+t1Mnnqe8Ia0BBTpbWF3wcBvPkNpVvGcBLy9pQsTt8A=; b=CsYbR9XUEcvZ++oa8NRcq8Zg0Qy7aSNKdXgcxpP1X5jWK6JPmpHLpCE3unJ/OtOUVx RE1BSgwjpQDGiBObAXY8Tv7Oy50sOm7A7+V8UZF4VFjym6s1yIDy7OaFCNHOxfmq+6AL siyhfwj6KyuVg5qlzZG83gOxJloRHiV4MmUb9APKk9ikehlcvVms4i/ikTWQPw70sx80 aBYzZJU+FuSF8lTTSasLO71cqr5lboUCAEYWiX3RUGZZciyzjkuYjXOkko6eckmrHYab S3XD22xvNmfYNRqk7KH+O0PCSVFOAMzUE2ALdXUAJ1C5ZoQBaNcJpyMuBu9BLjTv3CYo qjPA== MIME-Version: 1.0 X-Received: by 10.107.159.66 with SMTP id i63mr55611579ioe.68.1436882838599; Tue, 14 Jul 2015 07:07:18 -0700 (PDT) In-Reply-To: <55A51662.4090007@rece.vub.ac.be> References: <55A3A853.4040006@rece.vub.ac.be> <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> Date: Wed, 15 Jul 2015 00:07:18 +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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436882847 news.xs4all.nl 2963 [2001:888:2000:d::a6]:42736 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93814 On Wed, Jul 15, 2015 at 12:02 AM, Antoon Pardon wrote: > On 07/14/2015 03:43 PM, Chris Angelico wrote: >> On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa wrote: >>> Chris Angelico : >>> >>>> On Tue, Jul 14, 2015 at 10:28 PM, Marko Rauhamaa wrote: >>>>> I would rather optimize by default and disable optimizations with >>>>> --debug or equivalent. >>>> That assumes that it's simply an optimization. This is a distinct >>>> semantic change. >>> No, tail call optimization doesn't change the behavior of the program, >>> for the worse anyway. >> It does, because you lose traceback records. That's pretty significant >> when you come to try to debug something. > > I doubt it would be really significant. Not compared to writing it iteratively. > When you write it iteratively, you don't get to keep a traceback record per time > you go throught the loop. So the traceback records you loose in tale call elimination > would be the traceback records you wouldn't have anyway in the iterative version. > > So how would this be significant? You're proposing making _every_ instance of "return func(...)" into this kind of thing. That's not always recursion, and it's certainly not always clear what called what to get you there. ChrisA