Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1a.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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'true,': 0.05; 'compiler': 0.07; 'debug': 0.07; 'none,': 0.07; 'tries': 0.07; 'differently.': 0.09; 'immutable': 0.09; 'suggest': 0.14; 'binding,': 0.16; 'complicated,': 0.16; 'literals,': 0.16; 'mutable': 0.16; 'optional': 0.16; 'subject:parameters': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'sort': 0.25; 'references': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; "doesn't": 0.30; "d'aprano": 0.31; 'int,': 0.31; 'steven': 0.31; 'cases': 0.33; 'guess': 0.33; 'could': 0.34; "can't": 0.35; 'common': 0.35; 'except': 0.35; 'something': 0.35; 'late': 0.35; 'but': 0.35; 'false': 0.36; 'wrong': 0.37; 'to:addr :python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'expression': 0.60; 'name': 0.63; 'such': 0.63; 'different': 0.65; 'charset:windows-1252': 0.65; 'side': 0.67; 'received:74.208': 0.68; 'default': 0.69; 'evaluate': 0.72; 'obvious': 0.74; '2015': 0.84; 'optimized,': 0.84; 'absolutely': 0.87 Date: Sun, 10 May 2015 07:25:58 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: functions, optional parameters References: <72lu1cxvmg.ln2@news.c0t0d0s0.de> <554cd511$0$12979$c3e8da3$5496439d@news.astraweb.com> <554ec664$0$13001$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:OTNmExApjhE9FLLhAe1UU1g0zNE/KumVez/vRdp6cU6Hod2DhTQ Ma8K1UrMx4Y0WCIbtxgI49k/ludB90oytcWOugcsdXQZ0UBGY8lFjLHVv+1TF9k+QYeXE4c YssbuvQIU0YpxTLXwdfgMSvwadA3RcpcuX4aUsSM1EIodkN6VX5mMd6RwR0Hv9dRBUeoFhj 6fhRrtp7XETlmjvm59AMw== X-UI-Out-Filterresults: notjunk:1; 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431257173 news.xs4all.nl 2847 [2001:888:2000:d::a6]:33938 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90285 On 05/09/2015 11:33 PM, Chris Angelico wrote: > On Sun, May 10, 2015 at 12:45 PM, Steven D'Aprano > wrote: >> This is the point where some people try to suggest some sort of complicated, >> fragile, DWIM heuristic where the compiler tries to guess whether the user >> actually wants the default to use early or late binding, based on what the >> expression looks like. "0 is an immutable int, use early binding; [] is a >> mutable list, use late binding." sort of thing. Such a thing might work >> well for the obvious cases, but it would be a bugger to debug and >> work-around for the non-obvious cases when it guesses wrong -- and it will. > > What you could have is "late-binding semantics, optional early binding > as an optimization but only in cases where the result is > indistinguishable". That would allow common cases (int/bool/str/None > literals) to be optimized, since there's absolutely no way for them to > evaluate differently. > Except for literals, True, False and None, I can't see any way to optimize such a thing. Just because the name on the right side references an immutable object at compile time, it doesn't follow that it'll still be the same object later. Unless late binding means something very different than I understood. -- DaveA