Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'anyway.': 0.05; 'cpython': 0.05; 'interpreter': 0.05; 'discard': 0.07; 'returns,': 0.09; 'jan': 0.12; '10:00': 0.16; 'expression,': 0.16; 'loop.': 0.16; 'none.': 0.16; 'wrote:': 0.18; 'memory': 0.22; "shouldn't": 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; '13,': 0.31; 'away.': 0.31; 'received:google.com': 0.35; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'above,': 0.60; 'simple': 0.61; '2015': 0.84 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 :content-type; bh=40On3cv3mgBPmuvnKyPb4ZGKntK1wpD9PQYakx2rtWg=; b=ZNUWmgGpp5O1LT/cJDxM7YBbjxZK0GX6Sv+XM5lU9AE3ilaBp0V3LLZruvytUYd7KW hXlxisf9r2/WJb30YKE9BsQLDNvqZyTUlGBdaiBPG4H/dbDfcwkX0Fyjiry704NpkwZS hRcnBglsZYM0jgu8UaIyh8+qfIW68fvaDqMUclAwrSVxC361yuLjANcXl4nSKCiDl9eM ZfLJMslv00NhZBNsteJSIqEXK+9Yos5je3iclCYPX5qQH/nydjjt3obIa5trBhb/ZqmC Aw16y58Zc/8zVWJjHYvTy9bPDcirLFFyTxNkLsnbKcKFJ4Up6j/FWLJZjBK6nVdbZQnG bVVg== X-Received: by 10.68.65.108 with SMTP id w12mr53311610pbs.96.1421175422390; Tue, 13 Jan 2015 10:57:02 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <54ABB88A.7070504@r3dsolutions.com> <54ABC52A.1050507@davea.name> <54ABE383.3020801@r3dsolutions.com> <54AC97D9.4010504@r3dsolutions.com> <54ACAA04.60801@r3dsolutions.com> <54ADC99F.3020405@stoneleaf.us> <54B44A64.7010105@r3dsolutions.com> <54b4aded$0$2738$c3e8da3$76491128@news.astraweb.com> <87lhl7c5dt.fsf@elektro.pacujo.net> From: Ian Kelly Date: Tue, 13 Jan 2015 11:56:22 -0700 Subject: Re: Comparisons and sorting of a numeric class.... To: Python Content-Type: text/plain; charset=UTF-8 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: 10 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421175432 news.xs4all.nl 2921 [2001:888:2000:d::a6]:45803 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83718 On Tue, Jan 13, 2015 at 4:20 AM, Chris Angelico wrote: > On Tue, Jan 13, 2015 at 10:00 PM, Marko Rauhamaa wrote: >> The code above, though, shouldn't consume memory since it is a simple >> tail-recursive loop. > > Only if the interpreter can optimize it away. Bear in mind that it > doesn't _return_ the result of that expression, so it needs to take > whatever f() returns, discard it, and return None. And CPython doesn't even try to optimize tail recursion anyway.