Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.072 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.06; '(even': 0.05; 'subject:while': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'cc:name:python list': 0.16; 'subject:recursion': 0.16; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'something': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'either': 0.39; 'called': 0.40; 'how': 0.40; 'conservative': 0.84; 'procedural': 0.91; 'received:mail-wi0-x229.google.com': 0.91; 'washington': 0.93 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:to :cc:content-type; bh=GObgxUbOu8NxWpwzlJEpjBeRQoN73IDrDWhxaLrNQ9c=; b=eLG/hLYP4hBgxHbPHHjR3xffBICYamg0stLVw4OGUM5GRopwJOClKPmVnzbE9zGMgO UqIEsXA+SLX0QL/Yt+3DJekojAP1t4B4q8BNz+REQjS7hedNTiW4ShuZsqFJa+OW+FIX InoAZpqq9189Y0Pr10vJFk/gOYQLQ2pm5hQC3xrxfk24Z8QsP64/Hljo+LefQNjZbl75 nafb4ICzENKneNUNsAQn4XXj37NtWhkXvLjYFMGPEyjaDExlHOx32mDJs2x/L2qqySbV V/vxctfV+iHRJNyOLv095/YvbmWQkhdhceHXb1BuMOcmxiRxTReTI8AdLgVKCqniK/nV wyHg== MIME-Version: 1.0 X-Received: by 10.180.20.13 with SMTP id j13mr3429914wie.6.1380740390012; Wed, 02 Oct 2013 11:59:50 -0700 (PDT) In-Reply-To: <87had0axxy.fsf@dpt-info.u-strasbg.fr> References: <87had0axxy.fsf@dpt-info.u-strasbg.fr> Date: Wed, 2 Oct 2013 11:59:49 -0700 Subject: Re: Tail recursion to while iteration in 2 easy steps From: Mark Janssen To: Alain Ketterlin Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380740391 news.xs4all.nl 15884 [2001:888:2000:d::a6]:54316 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55375 >> def fact(n): return 1 if n <= 1 else n * fact(n-1) >> >> into a tail recursion like > [...] > > How do know that either "<=" or "*" didn't rebind the name "fact" to > something else? I think that's the main reason why python cannot apply > any procedural optimization (even things like inlining are impossible, > or possible only under very conservative assumption, that make it > worthless). It's called "operator precedence". -- MarkJ Tacoma, Washington