On 8/25/05, Mark Dickinson <[EMAIL PROTECTED]> wrote: > I have a simple 192-line Python script that begins with the line: > > dummy0 = 47 > > The script runs in less than 2.5 seconds. The variable dummy0 is never > referenced again, directly or indirectly, by the rest of the script. > > Here's the surprise: if I remove or comment out this first line, the > script takes more than 15 seconds to run. So it appears that adding a > redundant line produces a spectacular six-fold increase in speed! > > (Actually, I had to add 29 dummy lines at the beginning of the code to > get the speed increase; if any one of these lines is removed the > running time reverts to around 15 seconds again.) > > Questions: <snip>
One of my own: what in the world made you think "maybe I'll add 29 dummy global variables to speed things up?" It seems to work (>19x speedup on my machine), I'm just curious what path you followed to get there. And, finally, you should forward this to the python-dev list, if somebody hasn't already. There are more people who know a ton about python internals there. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list