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


Groups > comp.lang.python > #10754

Re: Early binding as an option

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'thread,': 0.04; 'cpython': 0.05; 'function,': 0.07; 'python': 0.08; 'declarations': 0.09; 'difference,': 0.09; 'globals': 0.09; 'variables,': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'archives.': 0.16; 'closure,': 0.16; 'devs': 0.16; "else's": 0.16; 'names;': 0.16; 'subject:Early': 0.16; "variable's": 0.16; 'cc:addr:python-list': 0.16; 'looked': 0.16; 'aug': 0.19; 'cheers,': 0.19; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'optional': 0.23; 'similarly': 0.23; 'smart': 0.23; 'thus': 0.23; 'tue,': 0.23; 'testing': 0.25; 'function': 0.26; "i'm": 0.27; 'changing': 0.28; '(see': 0.28; 'guess': 0.28; 'message-id:@mail.gmail.com': 0.28; 'accordingly.': 0.29; 'bound': 0.29; 'variables': 0.29; 'code,': 0.29; 'cc:addr:python.org': 0.30; 'example': 0.30; '"in': 0.30; 'binding': 0.30; 'chris': 0.32; 'despite': 0.32; 'proposed': 0.32; 'list': 0.32; 'done': 0.33; 'there': 0.34; 'someone': 0.34; 'all.': 0.35; 'here,': 0.35; 'pretty': 0.35; 'uses': 0.35; 'probably': 0.35; 'define': 0.35; 'certain': 0.36; 'regular': 0.36; 'thread': 0.37; 'anything': 0.37; 'some': 0.37; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85.161': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'else': 0.38; 'flexibility': 0.39; 'allows': 0.39; "there's": 0.39; 'received:209': 0.40; 'did': 0.40; 'perfect': 0.63; 'huge': 0.64; 'ever': 0.65; 'believe': 0.66; 'due': 0.66; 'here.': 0.66; 'engine': 0.71; 'binding.': 0.84; 'exploited': 0.84; 'realm': 0.84; 'seldom': 0.84; 'sender:addr:chris': 0.84; 'complexity': 0.93; 'factors': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=djGngWXC5816BVFBMHMMrqA3eAWnLrOAxOh/ggEqa1Q=; b=WAB/+i9vQscxPjNsbFPY2BPdOta1bICJdTgp9ktBKOShfInas76eTtwNx+PL0GgPgS F7tCbCst1pmhZv3kZCmClZ7DQJJUJEQ1sWaD/a3RRaMzzGvHMsvU2eunq0ElWYYBne/y IV1CcPoI3veA5i6rTWLhOhon9ZjYOcJrBIRbM=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <CAPTjJmpWN1Tq-46UoHjh_-q9ahkivTWmLJR3_eF9iThHwXQnhA@mail.gmail.com>
References <CAPTjJmpWN1Tq-46UoHjh_-q9ahkivTWmLJR3_eF9iThHwXQnhA@mail.gmail.com>
Date Tue, 2 Aug 2011 11:03:24 -0700
X-Google-Sender-Auth -LU43FEDJ6wZBwaU8Oa_DN52_j4
Subject Re: Early binding as an option
From Chris Rebert <clp2@rebertia.com>
To Chris Angelico <rosuav@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc python-list@python.org
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.1796.1312308207.1164.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312308207 news.xs4all.nl 23877 [2001:888:2000:d::a6]:38809
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10754

Show key headers only | View raw


On Tue, Aug 2, 2011 at 9:55 AM, Chris Angelico <rosuav@gmail.com> wrote:
> As I understand it, Python exclusively late-binds names; when you
> define a function, nothing is ever pre-bound. This allows a huge
> amount of flexibility (letting you "reach into" someone else's
> function and change its behaviour), but it's flexibility that most
> programs use seldom if at all.
>
> First off: Is there any way to request/cause some names to be bound
> early?

Nope. Even if you "freeze" a variable's value via a closure, I don't
believe it gets particularly optimized.

<snip>
> As an example of this difference, Pike uses early binding for some
> things; when I did the perfect numbers testing in the other thread
> (discussion thread, not thread of execution!), Pike performed
> significantly better; I believe this is in part due to the formal
> declarations of variables, and the consequential simplification of
> local code, although since there are no globals being looked up here,
> there's little to be gained from those.

"in part". There are very likely additional factors at work here.
Also, have you looked at Cython? I would guess that it can bypass a
lot of the late binding.

> Is this the realm of JIT compilation, or can it be done in regular CPython?

Smart enough JITers can infer that late binding is not being exploited
for certain variables and thus optimize them accordingly. Look how
fast some of the JavaScript VMs are, despite JavaScript also being
highly dynamic.

The CPython devs are reluctant to accept the increased complexity and
size of a JIT engine (see Unladen Swallow).
Anything else would probably involve a similarly unpalatable level of
complexity or require changing Python-the-language.

I'm pretty sure optional early binding has been proposed in the past;
try trawling the list archives.

Cheers,
Chris

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


Thread

Re: Early binding as an option Chris Rebert <clp2@rebertia.com> - 2011-08-02 11:03 -0700
  Re: Early binding as an option Teemu Likonen <tlikonen@iki.fi> - 2011-08-02 22:12 +0300

csiph-web