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


Groups > comp.lang.python > #10763

Re: Early binding as an option

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'cpython': 0.05; 'function,': 0.07; 'interpreter': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'python': 0.08; 'loop.': 0.09; 'namespace': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'wrote:': 0.15; 'arg': 0.16; 'efficiency.': 0.16; 'len': 0.16; 'lookup': 0.16; 'names;': 0.16; 'reedy': 0.16; 'subject:Early': 0.16; 'argument': 0.16; 'pm,': 0.16; 'of.': 0.19; 'repeated': 0.19; 'convert': 0.19; 'jan': 0.19; 'language': 0.20; 'header:In-Reply- To:1': 0.22; 'slots': 0.23; 'unlikely': 0.23; 'code': 0.24; "python's": 0.25; '(or': 0.25; 'function': 0.26; '(in': 0.26; 'objects': 0.28; 'bound': 0.29; 'expressions': 0.29; 'definition': 0.30; '*and*': 0.30; 'yet': 0.30; 'developers': 0.32; 'chris': 0.32; 'too': 0.32; 'rather': 0.33; 'anyone': 0.33; 'actually': 0.33; 'to:addr:python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'header:User-Agent:1': 0.34; '(as': 0.34; 'languages.': 0.35; 'machine': 0.35; 'define': 0.35; 'idea': 0.36; 'but': 0.37; 'several': 0.37; 'could': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'think': 0.38; 'else': 0.38; 'easier': 0.39; 'header :Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'give': 0.60; 'ever': 0.65; 'revealed': 0.68; 'periodically': 0.73; 'proposals.': 0.84; 'examined': 0.91; 'presumably': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Early binding as an option
Date Tue, 02 Aug 2011 16:23:21 -0400
References <CAPTjJmpWN1Tq-46UoHjh_-q9ahkivTWmLJR3_eF9iThHwXQnhA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-74-109-121-73.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0
In-Reply-To <CAPTjJmpWN1Tq-46UoHjh_-q9ahkivTWmLJR3_eF9iThHwXQnhA@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1801.1312316615.1164.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312316615 news.xs4all.nl 23982 [2001:888:2000:d::a6]:42750
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10763

Show key headers only | View raw


On 8/2/2011 12:55 PM, Chris Angelico wrote:
> As I understand it, Python exclusively late-binds names; when you
> define a function, nothing is ever pre-bound.

By 'pre-bound' you presumably mean bound at definition time rather than 
call time. Default arg objects *are* pre-computed and pre-bound to 
internal slots at definition time.

> Argument in favour: Efficiency is also a Good Thing, and with staples
> like 'len', it's unlikely anyone will want to change them - yet the
> interpreter still has to do a namespace lookup every time.

Three approaches to machine efficiency.

1. Better algorithm: Python's people efficiency makes this easier than 
in most other languages.

2. Hand-optimize the code that actually chew up time (as revealed by 
profiler). This often means removing repeated expressions *and* global 
names from inner loops.

     _len = len
     for line in somefile:
         n = _len(line)

*might* give a worthwhile speedup in a function if not too much else 
happends in the loop. But the CPython global name lookup code (in C) has 
been thoroughly examined and optimized as best as several developers 
could think of.

3. Convert critical code to native language (or C).

The idea of 'early binding' comes up periodically but I do not remember 
many concrete proposals.

-- 
Terry Jan Reedy

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


Thread

Re: Early binding as an option Terry Reedy <tjreedy@udel.edu> - 2011-08-02 16:23 -0400

csiph-web