Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed3.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'from:addr:yahoo.co.uk': 0.04; 'languages.': 0.04; 'method.': 0.07; '(ie.': 0.09; 'high-level': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'language.': 0.14; "'b'": 0.16; '(it': 0.16; 'consulted': 0.16; 'dict': 0.16; 'instantiated': 0.16; 'lookups': 0.16; "object's": 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'type)': 0.16; 'language': 0.16; 'wrote:': 0.18; 'looked': 0.18; "python's": 0.19; 'programming': 0.22; 'header:User-Agent:1': 0.23; '(or': 0.24; 'possibly': 0.26; 'this:': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'feature': 0.29; 'words': 0.29; 'easier': 0.31; 'usually': 0.31; 'class': 0.32; 'call.': 0.33; 'something': 0.35; 'anybody': 0.35; 'done': 0.36; 'method': 0.36; 'searching': 0.37; 'so,': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'expression': 0.60; 'first': 0.61; 'show': 0.63; 'name': 0.63; 'our': 0.64; 'more': 0.64; 'charset:windows-1252': 0.65; 'sound': 0.68; 'construction': 0.72; 'delegates': 0.74; "class's": 0.84; 'received:as9105.com': 0.84; 'received:dsl.as9105.com': 0.84; 'received:dynamic.dsl.as9105.com': 0.84; 'picture': 0.97 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Building CPython Date: Sat, 16 May 2015 00:27:58 +0100 References: <7JN4x.37133$Q41.15375@fx25.am4> <6w35x.645690$I97.19867@fx31.am4> <874mnfunpn.fsf@elektro.pacujo.net> <87bnhmgqrx.fsf@elektro.pacujo.net> <87twvdsbom.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 80-44-148-0.dynamic.dsl.as9105.com User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: <87twvdsbom.fsf@elektro.pacujo.net> 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431732529 news.xs4all.nl 2893 [2001:888:2000:d::a6]:33332 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90697 On 15/05/2015 23:44, Marko Rauhamaa wrote: > BartC : > >> What /is/ a method lookup? Is it when you have this: >> >> A.B() >> >> and need to find whether the expression A (or its class or type) has a >> name B associated with it? (And it then needs to check whether B is >> something that can be called.) >> >> If so, does that have to be done using Python's Dict mechanism? (Ie. >> searching for a key 'B' by name and seeing if the object associated >> with it is a method. That does not sound efficient.) > > That is a general feature among high-level programming languages. In > Python, it is even more complicated: > > * first the object's dict is looked up for the method name > > * if the method is not found (it usually isn't), the dict of the > object's class is consulted > > * if the method is found (it usually is), a function object is > instantiated that delegates to the class's method and embeds a "self" > reference to the object to the call > > IOW, two dict lookups plus an object construction for each method call. > > > Marko > As a picture paints a thousand words is anybody aware of a site or sites that show this diagramatically, as I think I and possibly others would find it far easier to grasp. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence