[Python-Dev] patch: speed up name access by up to 80%

Oren Tirosh oren-py-d@hishome.net
Tue, 12 Feb 2002 09:05:14 +0200


On Mon, Feb 11, 2002 at 07:14:25PM -0500, Jeremy Hylton wrote:
> So simple benchmark programs are a lot more interesting.
> 
> I'd pick pystone, test_hmac, and test_htmlparser.

test_htmlparser (x100):	0m29.950s	0m29.730s
test_hmac (x1000):	0m16.480s	0m15.720s  (lower is better)
pystone:		11261.3		11494.3	   (higher is better)

A small, but measureable improvement.  You can see below that most accesses 
are still to fastlocals and, of course, the code has some real work to do 
other than looking up names.  

test_htmlparser:
362331 fastlocal non-dictionary lookups
60106 inline dictionary lookups
10554 fast dictionary lookups
151 slow dictionary lookups

test_hmac:
13959 fastlocal non-dictionary lookups
9920 inline dictionary lookups
7548 fast dictionary lookups
240 slow dictionary lookups

pystone:
1447094 fastlocal non-dictionary lookups
502190 inline dictionary lookups
111549 fast dictionary lookups
111 slow dictionary lookups

Anyone has an example of a program that relies on a lot of global and 
builtin name accesses?  Meanwhile I'm going to start working on LOAD_ATTR.

    if-the-evidence-doesn't-fit-the-theory...-ly yours,

	Oren