[Python-Dev] Patch to use dict subclasses in eval(), exec
Jeff Epler
jepler@unpythonic.net
Tue, 29 Oct 2002 11:10:25 -0600
Still working from the version which is missing DECREFs, I get these
timings from a program intended to more directly measure the speed of
local, global, and builtin name lookups:
Vanilla Python CVS. In effect these are three runs of the same thing,
so you get some idea of the timing variations on my system.
$ python-cvs/python lookup-speed.py
Timing 4000000 name lookups
type builtin global local overhead
dict 2.74015 1.99215 1.21323 0.17610
D 2.69901 1.99129 1.24662 0.17832
E 2.73839 2.03171 1.25233 0.17843
CVS with my original patch (leaks references). "D" is a dict subclass
which doesn't define __getitem__, "E" is a dict subclass which does
(simply calling dict.__getitem__ and returning the result)
$ python-dict/python lookup-speed.py
Timing 4000000 name lookups
type builtin global local overhead
dict 2.81268 2.04795 1.26585 0.18117
D 5.08308 2.85853 1.23625 0.17944
E 81.62213 64.60481 1.26524 0.17973
This is a ~3% slowdown on the test with the heaviest use of builtins
and globals that I can think of offhand. Slowdown:
builtin global
dict 3% 3%
D 80% 40%
E *28 *31
I'm about done pretending to cheerlead for this patch, though if I fix
the reference problem I'll post the revised diffs.
Jeff