Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'algorithm': 0.04; 'explicitly': 0.05; 'interpreter': 0.05; 'memory.': 0.07; 'suppose': 0.07; '22,': 0.09; 'function,': 0.09; 'high-level': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'language,': 0.12; 'assume': 0.14; 'language.': 0.14; 'blanket': 0.16; 'extension,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'feb': 0.22; 'programming': 0.22; 'coding': 0.22; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'recognize': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'waste': 0.30; 'message-id:@mail.gmail.com': 0.30; 'along': 0.30; 'work.': 0.31; 'that.': 0.31; 'evil': 0.31; 'programmers': 0.33; 'received:google.com': 0.35; 'leads': 0.36; 'should': 0.36; 'level': 0.37; 'pm,': 0.38; 'that,': 0.38; 'either': 0.39; 'how': 0.40; 'even': 0.60; 'you.': 0.62; 'high': 0.63; 'such': 0.63; 'advantages': 0.68; 'helping': 0.70; 'computers': 0.72; 'subject:Design': 0.78; '2015': 0.84; 'optimized,': 0.84; 'subject:thought': 0.84; 'to:none': 0.92 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=AFPH1wi0Dfqeww0cbivjqR0jX3alzLxMILPY4pRA768=; b=MxROLVfF1IfWKQxa4xYRu+TVbPZqVOTvtlNaqRTUSZFhfmsgYXrWYiQWQE1urit+9b mjS2CcwrS/yLN6TJq4Wk8imQV7IRMRvwozI6oVGdc9xIiVyUyU4ixfkiAaxvmSNW+Noi FFkEs520V1GjYd827x4jQnH5OWNalCCDOcMLYg3oAkjTAR+lRy/G/JoK/VNK3taV4asK giL1uo1Vhs0zYF5nthsVx3NTpv9EHEXnOKnC403MPCXI6oFwqKY6FQRkfixcRILQmF24 wGAV6pH0qz73DK9NvXG5Tuj3jxcS8UXbMQUZHBDY8S0BjtbrS9mtV34AIkrnKkAbPnyy rQoQ== MIME-Version: 1.0 X-Received: by 10.50.114.4 with SMTP id jc4mr6786347igb.14.1424600477924; Sun, 22 Feb 2015 02:21:17 -0800 (PST) In-Reply-To: <87ioeui9zd.fsf@elektro.pacujo.net> References: <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <87egpjapxv.fsf@elektro.pacujo.net> <54e9391b$0$13010$c3e8da3$5496439d@news.astraweb.com> <87r3tiids7.fsf@elektro.pacujo.net> <87mw46ibtq.fsf@elektro.pacujo.net> <87ioeui9zd.fsf@elektro.pacujo.net> Date: Sun, 22 Feb 2015 21:21:17 +1100 Subject: Re: Design thought for callbacks 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.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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424600480 news.xs4all.nl 2932 [2001:888:2000:d::a6]:44742 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86093 On Sun, Feb 22, 2015 at 8:14 PM, Marko Rauhamaa wrote: >> Helping it along means your program doesn't waste memory. Why such a >> blanket statement? > > Because worrying Python programmers with evil spirits (reference loops) > leads to awkward coding practices and takes away one of the main > advantages of Python as a high-level programming language. Right, and I suppose that, by extension, we should assume that the Python interpreter can optimize this? def fib(x): if x<2: return x return fib(x-2)+fib(x-1) Just because a computer can, in theory, recognize that this is a pure function, doesn't mean that we can and should depend on that. If you want this to be optimized, you either fix your algorithm or explicitly memoize the function - you don't assume that Python can do it for you. Even when you write in a high level language, you need to understand how computers work. ChrisA