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


Groups > comp.lang.python > #10755

Re: Early binding as an option

Date 2011-08-02 20:10 +0200
From Thomas Jollans <t@jollybox.de>
Subject Re: Early binding as an option
References <CAPTjJmpWN1Tq-46UoHjh_-q9ahkivTWmLJR3_eF9iThHwXQnhA@mail.gmail.com> <4E38315C.1000102@jollybox.de> <CAPTjJmqfi8YfSYU8wHMZCxQ-3iYim+TOfq9qwn3MOq695R2Cgw@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1797.1312308603.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 02/08/11 19:42, Chris Angelico wrote:
> On Tue, Aug 2, 2011 at 6:18 PM, Thomas Jollans <t@jollybox.de> wrote:
>> I suppose it would be possible to introduce a kind of "constant
>> globals" namespace that a JIT compiler could then use to optimise, but
>> how much would this help?
> 
> Surely it must help a lot; looking up names is string operations. If
> "len" could be replaced with "@10794928" where 10794928 is the actual
> address of the len object, then it'd be doing no work that isn't
> normally done, and would go straight to the object and call it.
> 
> But I don't really know how to go about profiling this to be sure. Any ideas?

Well, you could run a direct comparison of one function where len is
global, and an identitical function where len is local (which does not
do a dict lookup, am I right?)

Of course the global dict lookup takes time, but I doubt that many
modules look up the same name often enough for it to actually be
significant.

I don't really know enough about either profiling or the CPython
interpreter, but I assume there's some function that's called to look up
globals; you could profile the Python interpreter (don't ask me with
which tool) and see how much time that function uses.

Thomas

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


Thread

Re: Early binding as an option Thomas Jollans <t@jollybox.de> - 2011-08-02 20:10 +0200

csiph-web