Path: csiph.com!news.swapon.de!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: Tue, 22 Mar 2016 07:44:17 +0000 Lines: 62 Message-ID: References: <56e44258$0$1598$c3e8da3$5496439d@news.astraweb.com> <8737rvxs89.fsf@elektro.pacujo.net> <56e7483d$0$1608$c3e8da3$5496439d@news.astraweb.com> <56f0ebe5$0$1497$c3e8da3$5496439d@news.astraweb.com> <8737rj561a.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de GBv0cXqBCw9ZxKBLqiaJHw/Vhm6kap21IZMj6IHVbeUA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'float': 0.05; 'from:addr:yahoo.co.uk': 0.05; '*is*': 0.09; '[])': 0.09; 'abstraction': 0.09; 'docs.': 0.09; 'interpreter,': 0.09; 'likewise': 0.09; 'objects.': 0.09; 'pointers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'slow.': 0.09; 'subject:which': 0.09; 'terms,': 0.09; 'python': 0.10; 'python.': 0.11; 'applies': 0.15; '"write': 0.16; '*before*': 0.16; '1.5,': 0.16; '2016': 0.16; 'applaud': 0.16; 'devil': 0.16; 'guessing': 0.16; 'ironpython': 0.16; 'pointers,': 0.16; 'pointers.': 0.16; 'received:194.126': 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; 'wrote:': 0.16; "wouldn't": 0.16; 'implementing': 0.18; 'passes': 0.18; 'language': 0.19; '>>>': 0.20; 'versions': 0.20; 'algorithm': 0.20; 'lawrence': 0.22; 'pass': 0.22; 'trying': 0.22; 'programming': 0.22; 'code,': 0.23; '(or': 0.23; "python's": 0.23; 'references': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'define': 0.27; 'references.': 0.29; 'sure,': 0.29; 'objects': 0.29; "i'm": 0.30; 'that.': 0.30; 'code': 0.30; 'certainly': 0.30; '"the': 0.32; 'anybody': 0.32; 'functional': 0.32; 'language.': 0.32; 'point': 0.33; 'url:python': 0.33; 'choosing': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'suddenly': 0.33; 'list': 0.34; 'could': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'received:org': 0.37; 'no,': 0.38; 'mean': 0.38; 'data': 0.39; 'along': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'mark': 0.40; 'url:3': 0.60; 'ever': 0.60; 'subject:The': 0.61; 'entire': 0.61; 'received:194': 0.61; 'charset:windows-1252': 0.62; 'different': 0.63; 'our': 0.64; 'march': 0.64; 'detail.': 0.66; 'here': 0.66; 'fact,': 0.67; 'situation': 0.67; 'natural': 0.67; 'attention': 0.76; 'around,': 0.84; 'fact.': 0.84; 'hood': 0.84; 'prolog': 0.84; 'pythonistas,': 0.84; 'url:datamodel': 0.84; 'whereby': 0.84; 'url:reference': 0.91; 'imagine': 0.96 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 248.80.126.194.pool.dsl.daisyplc.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 In-Reply-To: <8737rj561a.fsf@elektro.pacujo.net> 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:105449 On 22/03/2016 07:24, Marko Rauhamaa wrote: > Steven D'Aprano : > >> I applaud you writing different versions of code to try different >> tactics, but you should start from "write the most natural Python code >> you can" *before* you trying guessing what's fast and what's slow. > > I'm hard-pressed to imagine a situation where I would write *unnatural* > Python code for performance gains. Choosing a good algorithm applies to > Python programming as well, but convoluted optimization tricks, hardly. > >> On Tuesday 22 March 2016 11:49, BartC wrote: >>> No, it passes only a reference to the entire string. >> >> In Python terms, that *is* "the entire string". >> >> The point is, under the hood of the interpreter, *everything* passes >> along references. We rarely draw attention to this fact. Given: >> >> function(1.5, []) >> >> we say "pass the float 1.5 and an empty list to function", not "pass a >> reference to the float 1.5 and a reference to an empty list to a >> reference to the function", because that would get rather annoying >> quickly. > > Hm. Annoying to repeat, sure, but I don't know how you could extricate > pointers from Python's abstract data model (or Java's, or Lisp's). > Prolog or a purely functional programming language could get away > without pointers but not Python. I don't recall seeing any reference to "pointers" above. In fact, I don't ever recall seeing references to pointers in the Python docs. There's certainly nothing here https://docs.python.org/3/reference/datamodel.html > >> But that's the critical point: it is *behind the scenes*, an >> implementation detail. > > I don't think there is any way to implement, think about or define > Python without pointers. I never think about pointers, I think about objects. Heck, I wouldn't have a clue as to how you go about implementing Jython or IronPython in terms of pointers. I don't even know what anybody could mean by that. > >> In Python code, you don't pass "a reference to" 1.5, you pass 1.5. >> Likewise for all other objects. The abstraction is that you pass >> objects around, not references to objects. > > The devil is in the mutables... Whereby these mysterious "pointers" suddenly leap into action I take it? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence