Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #90704

Re: Building CPython

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
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; 'python,': 0.02; 'languages.': 0.04; 'cpython': 0.05; 'interpreter': 0.05; 'layers': 0.07; 'method.': 0.07; 'suppose': 0.07; '(ie.': 0.09; 'attributes': 0.09; 'exist,': 0.09; 'high-level': 0.09; 'oop,': 0.09; 'python': 0.11; 'anyway': 0.14; 'language.': 0.14; "'b'": 0.16; '(it': 0.16; 'bytecode': 0.16; 'conditional': 0.16; 'consulted': 0.16; 'dict': 0.16; 'distinct': 0.16; 'enough.': 0.16; 'for,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'instantiated': 0.16; 'itself,': 0.16; 'lookups': 0.16; 'macros': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; "object's": 0.16; 'ought': 0.16; 'received:192.168.1.4': 0.16; 'type)': 0.16; 'language': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'trying': 0.19; "python's": 0.19; '>>>': 0.22; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'rapidly': 0.24; '(or': 0.24; 'question': 0.24; 'equivalent': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'appear': 0.29; 'feature': 0.29; "i'm": 0.30; 'code': 0.31; 'usually': 0.31; 'minor': 0.31; 'own,': 0.31; 'class': 0.32; 'call.': 0.33; 'cases': 0.33; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'really': 0.36; 'belong': 0.36; 'crazy': 0.36; 'done': 0.36; "didn't": 0.36; 'method': 0.36; 'possible': 0.36; 'searching': 0.37; 'so,': 0.37; 'two': 0.37; 'represent': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'does': 0.39; 'use.': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'expression': 0.60; 'first': 0.61; 'name': 0.63; 'such': 0.63; 'more': 0.64; 'sound': 0.68; 'construction': 0.72; 'delegates': 0.74; 'increase': 0.74; 'special': 0.74; 'gain': 0.79; '(increase': 0.84; "class's": 0.84; 'details...': 0.84; 'do:': 0.91; 'urge': 0.91
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=DZWZq5dW c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=SY9aFQKHIdAA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=5ANokUeuAAAA:8 a=B5DUjjRS0Nhm-CzFEEYA:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett@:2500
Date Sat, 16 May 2015 02:16:52 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Building CPython
References <7JN4x.37133$Q41.15375@fx25.am4> <mailman.464.1431556504.12865.python-list@python.org> <6w35x.645690$I97.19867@fx31.am4> <874mnfunpn.fsf@elektro.pacujo.net> <zR85x.441429$Zf4.246168@fx22.am4> <xpb5x.597872$X95.548374@fx10.am4> <crlglfFgf05U1@mid.individual.net> <87bnhmgqrx.fsf@elektro.pacujo.net> <DWt5x.439666$qW.359562@fx20.am4> <87twvdsbom.fsf@elektro.pacujo.net> <bpw5x.561870$Zf4.150532@fx22.am4>
In-Reply-To <bpw5x.561870$Zf4.150532@fx22.am4>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.53.1431739023.17265.python-list@python.org> (permalink)
Lines 62
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1431739023 news.xs4all.nl 2924 [2001:888:2000:d::a6]:56362
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:90704

Show key headers only | View raw


On 2015-05-16 01:43, BartC wrote:
> On 15/05/2015 23:44, Marko Rauhamaa wrote:
>> BartC <bc@freeuk.com>:
>>
>>> 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.
>
> OK, I didn't know that objects have their own set of attributes that are
> distinct from the class they belong to. I really ought to learn more
> Python!.
>
> (Yet, I have this crazy urge now to create my own bytecode interpreter
> for, if not exactly Python itself, then an equivalent language. Just to
> see if I can do any better than CPython, given the same language
> restraints.
>
> Although I'm hampered a little by not knowing Python well enough. Nor
> OOP, but those are minor details... Anyway it sounds more fun than
> trying to decipher the layers of macros and conditional code that appear
> to be the CPython sources.)
>
>   > IOW, two dict lookups plus an object construction for each method call.
>
> I suppose in many cases an object will have no attributes of its own,
> and so it can rapidly bypass the first lookup. I don't understand the
> need for an object creation (to represent A.B so that it can call it?)
> but perhaps such an object can already exist, prepared ready for use.
>
It's possible to do:

     f = A.B
     ...
     f()

so it's necessary to have an object for A.B.

The question is how much you would gain from optimising A.B() as a
special case (increase in speed vs increase in complexity).

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Building CPython BartC <bc@freeuk.com> - 2015-05-13 20:36 +0100
  Re: Building CPython Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-13 20:58 +0100
  Re: Building CPython Terry Reedy <tjreedy@udel.edu> - 2015-05-13 18:34 -0400
    Re: Building CPython BartC <bc@freeuk.com> - 2015-05-14 16:51 +0100
      Re: Building CPython Chris Angelico <rosuav@gmail.com> - 2015-05-15 02:09 +1000
        Re: Building CPython BartC <bc@freeuk.com> - 2015-05-14 18:02 +0100
          Re: Building CPython Dave Angel <davea@davea.name> - 2015-05-14 13:10 -0400
          Re: Building CPython Chris Angelico <rosuav@gmail.com> - 2015-05-15 03:11 +1000
            Re: Building CPython BartC <bc@freeuk.com> - 2015-05-14 18:32 +0100
              Re: Building CPython Chris Angelico <rosuav@gmail.com> - 2015-05-15 03:45 +1000
          Re: Building CPython Terry Reedy <tjreedy@udel.edu> - 2015-05-14 14:50 -0400
            Re: Building CPython Christian Gollwitzer <auriocus@gmx.de> - 2015-05-15 12:51 +0200
              Re: Building CPython Terry Reedy <tjreedy@udel.edu> - 2015-05-15 17:19 -0400
      Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-14 19:29 +0300
        Re: Building CPython BartC <bc@freeuk.com> - 2015-05-14 22:55 +0100
          Re: Building CPython MRAB <python@mrabarnett.plus.com> - 2015-05-14 23:19 +0100
          Re: Building CPython BartC <bc@freeuk.com> - 2015-05-15 01:50 +0100
            Re: Building CPython Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-05-15 18:05 +1200
              Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-15 11:59 +0300
                Re: Building CPython wxjmfauth@gmail.com - 2015-05-15 02:07 -0700
                Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-15 12:20 +0300
                Re: Building CPython wxjmfauth@gmail.com - 2015-05-15 02:51 -0700
                Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-15 13:52 +0300
                Re: Building CPython Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-15 22:10 +1000
                Re: Building CPython Chris Angelico <rosuav@gmail.com> - 2015-05-15 22:34 +1000
                Re: Building CPython wxjmfauth@gmail.com - 2015-05-15 07:11 -0700
                Re: Building CPython Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-15 13:41 +0100
                Re: Building CPython Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-15 13:38 +0100
                Re: Building CPython Chris Angelico <rosuav@gmail.com> - 2015-05-15 19:43 +1000
                Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-15 13:50 +0300
                Re: Building CPython Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-15 22:43 +1000
                Re: Building CPython Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-15 09:00 -0600
                Re: Building CPython Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-15 09:04 -0600
                Re: Building CPython Chris Angelico <rosuav@gmail.com> - 2015-05-16 01:06 +1000
                Re: Building CPython Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-15 20:14 +1000
                Re: Building CPython Chris Angelico <rosuav@gmail.com> - 2015-05-15 20:25 +1000
                Re: Building CPython Terry Reedy <tjreedy@udel.edu> - 2015-05-15 17:05 -0400
                Re: Building CPython BartC <bc@freeuk.com> - 2015-05-15 22:54 +0100
                Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-16 01:44 +0300
                Re: Building CPython Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-16 00:27 +0100
                Re: Building CPython Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-16 11:55 +1000
                Re: Building CPython Chris Angelico <rosuav@gmail.com> - 2015-05-16 12:15 +1000
                Re: Building CPython Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-16 03:17 +0100
                Re: Building CPython BartC <bc@freeuk.com> - 2015-05-16 01:43 +0100
                Re: Building CPython MRAB <python@mrabarnett.plus.com> - 2015-05-16 02:16 +0100
                Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-16 11:08 +0300
                Re: Building CPython Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-16 19:40 +1000
                Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-16 16:59 +0300
                Re: Building CPython Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-17 04:18 +1000
                Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-16 21:55 +0300
                Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-17 01:51 +0300
                Re: Building CPython Marko Rauhamaa <marko@pacujo.net> - 2015-05-17 23:49 +0300
                Re: Building CPython Terry Reedy <tjreedy@udel.edu> - 2015-05-15 19:54 -0400
              Re: Building CPython BartC <bc@freeuk.com> - 2015-05-15 10:32 +0100
                Re: Building CPython Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-05-16 12:55 +1200
                Re: Building CPython Jonas Wielicki <jonas@wielicki.name> - 2015-05-17 14:25 +0200
                Re: Building CPython BartC <bc@freeuk.com> - 2015-05-17 14:41 +0100

csiph-web