Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.100 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.82; '*S*': 0.02; 'stack.': 0.09; 'subject:while': 0.09; 'cc:addr:python-list': 0.11; 'other,': 0.16; 'ravi': 0.16; 'subject:recursion': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'example': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'push': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'received:google.com': 0.35; 'there': 0.35; 'thanks': 0.36; 'example,': 0.37; 'does': 0.39; 'further': 0.61; 'address': 0.63; 'such': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'optimized': 0.68; 'studying': 0.84; 'rusi': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Eh4CZCVnjOD1bmT6JflrTVj4jypRFbQflXQcDNGeLeo=; b=MrvxFWO8Orj8bH6g3khWYCb+JVl9Rcq25s10Aw4w8185MuZaY/KuyQosfLIrKHW5Vp tpwCcaniQv5fYJlPrjMSWaSJuKFrqo2Lff/IxDa+zIFEEki6b3ohDff/ZvcYqz2ck6yf sE1nu+KYu+UZ1/4FAqYNYLu2KZbaTeNyzTGbNc2o+G/lWWWtw2CEmvj5/bueObRfRN/P nkNoZsmtEwi1xql1xtMPTdjxa65dz+YiOIezYcvp/udfG8rJRuPkjv01LIL2UZ8UtLIN kXTpPTOsGfKI9aypUqrBLxrIIkwUlHEXyiPtJn8bZIU0+FX0EMSXKK/VRILK+lo2kaNI d79g== X-Received: by 10.66.146.42 with SMTP id sz10mr10992254pab.100.1380821289020; Thu, 03 Oct 2013 10:28:09 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <22277f09-f230-4cc9-914e-0b4b63fc0060@googlegroups.com> References: <22277f09-f230-4cc9-914e-0b4b63fc0060@googlegroups.com> From: Ravi Sahni Date: Thu, 3 Oct 2013 22:57:48 +0530 Subject: Re: Tail recursion to while iteration in 2 easy steps To: rusi Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380821298 news.xs4all.nl 15930 [2001:888:2000:d::a6]:34443 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55426 On Wed, Oct 2, 2013 at 10:46 AM, rusi wrote: > 4. There is a whole spectrum of such optimizaitons -- > 4a eg a single-call structural recursion example, does not need to push return address on the stack. It only needs to store the recursion depth: > > If zero jump to outside return add; if > 0 jump to internal return address > > 4b An example like quicksort in which one call is a tail call can be optimized with your optimization and the other, inner one with 4a above I am interested in studying more this 'whole spectrum of optimizations' Any further pointers? Thanks -- Ravi