Speed *triples* by changing 'apply(f, args)' to 'f(*args)'
Andrew Dalke
adalke at mindspring.com
Tue Mar 4 18:12:57 EST 2003
Gerrit Holl:
> I was having troubles with a low framespeed. In my game,
> 1/3'rd of the time was in the warn() function:
There's an annoying feature in python that various things
generate warnings, which the warning module suppresses. This
is more annoying in the performance sense, because it's hard to
see something which isn't there.
You should be able to get a list of those warnings with the
-Wall
command-line argument to Python.
> Then I changed in sprite.py:311, apply(f, args) to f(*args).
> Framespeed tripled:
Huh. I wouldn't have thought it would be that fast. The first
requires a builin lookup for 'apply', local lookups for 'f' and
'args', and two function calls. The latter only requires the two
local lookups and a single function call.
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list