Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?) Date: Mon, 14 Mar 2016 21:00:18 +0000 Lines: 75 Message-ID: References: <87h9gcxkd3.fsf@elektro.pacujo.net> <87shzvgbhq.fsf@elektro.pacujo.net> <56e44a4e$0$1614$c3e8da3$5496439d@news.astraweb.com> <56e5354c$0$1593$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de sHCG4inIidQy+GtuuL9VFwGO5xxtIBVJop8EFDXFRy3Q== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'anyway.': 0.04; 'from:addr:yahoo.co.uk': 0.05; "'a'": 0.07; 'python:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:which': 0.09; 'python': 0.10; 'def': 0.13; '2016': 0.16; 'confusion': 0.16; 'fly': 0.16; 'programmers,': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:?)': 0.16; 'tying': 0.16; 'wrote:': 0.16; 'case.': 0.18; 'passes': 0.18; 'pointer': 0.18; 'refers': 0.18; 'tells': 0.18; 'language': 0.19; '>>>': 0.20; 'so.': 0.22; 'latter': 0.22; 'lawrence': 0.22; 'rid': 0.22; 'pass': 0.22; 'am,': 0.23; 'code,': 0.23; 'references': 0.23; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; 'mon,': 0.24; 'header:User-Agent:1': 0.26; 'example': 0.26; 'header:X-Complaints-To:1': 0.26; 'sense': 0.26; 'have,': 0.27; 'function': 0.28; 'values': 0.28; "people's": 0.29; "i'm": 0.30; 'print': 0.30; 'language.': 0.32; 'useful': 0.33; 'common': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'languages': 0.34; 'gets': 0.35; 'displays': 0.35; 'replace': 0.35; 'something': 0.35; 'but': 0.36; 'instead': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'received:org': 0.37; 'names': 0.38; 'to:addr:python.org': 0.40; 'mark': 0.40; 'called': 0.40; 'your': 0.60; 'subject:The': 0.61; 'charset:windows-1252': 0.62; 'more': 0.63; 'different': 0.63; 'to,': 0.63; 'our': 0.64; 'mar': 0.65; '>>>>>': 0.66; 'wanting': 0.66; 'below.': 0.66; 'talking': 0.67; 'worth': 0.67; '100': 0.79; 'itself?': 0.84; 'pythonistas,': 0.84; 'write:': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 80.234.129.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104861 On 14/03/2016 20:31, BartC wrote: > On 14/03/2016 19:45, alister wrote: >> On Mon, 14 Mar 2016 14:43:22 +0000, BartC wrote: >> >>> On 13/03/2016 09:39, Steven D'Aprano wrote: >>>> On Sun, 13 Mar 2016 04:54 am, BartC wrote: >>> >>>>> Common sense tells you it is unlikely. >>>> >>>> Perhaps your common sense is different from other people's common >>>> sense. To me, and many other Python programmers, it's common sense that >>>> being able to replace functions or methods on the fly is a useful >>>> feature worth having. More on this below. >>>> >>>> Perhaps this is an example of the "Blub Paradox": >>> >>> Perhaps it's time to talk about something which many languages have, but >>> Python hasn't. Not as far as I know anyway. >>> >>> That's references to names (sometimes called pointers). So if I write: >>> >>> a = 100 f(a) >>> >>> then function f gets passed the value that a refers to, or 100 in this >>> case. But how do you pass 'a' itself? > >> Congratulations >> you have just proven that you have faild in your understanimg of python @ >> stage 1 becuae you keep tying to us it a C >> >> try the following >> >> def test(x): >> print (id(x) >> >> a=100 >> print (id(a)) >> test(a) >> a="Oops i was an idiot" >> print (id(a)) >> test(a) >> >> python always passes the object bound to a, not the value of a or a >> pointer to a > > Yes, and? I colloquially used 'value' instead of 'object', 'id' or > 'reference'. The latter would added confusion as I'm talking about a > different kind of reference. And if you get rid of 'id' in your code, > you will get values displayed. > > But how do you pass something that refers to a itself? > > There are good reasons for wanting to do so. Try writing this function > in Python: > > def swap(a,b): > b,a = a,b > > x="one" > y="two" > swap(x,y) > > print (x,y) > > so that it displays "two" "one". > Global. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence