[Tutor] python, speed, game programming

Steven D'Aprano steve at pearwood.info
Sat Jan 4 13:15:18 CET 2014


On Fri, Jan 03, 2014 at 08:38:47PM -0500, Keith Winston wrote:
> The thing that put me on edge was noticing that my simple
> Chutes & Ladders game doesn't go ANY faster on a machine that benchmarks
> perhaps 1000 times faster than another...

Damn! You've discovered our secret! Hidden deep insight the Python 
compiler is code that determines the speed of computer, and deliberately 
slows down the Python runtime so that it runs just as slowly on all PCs, 
no matter how fast they are or how much memory they have... 

*wink*

But seriously... This is clearly bogus. There has to be an explanation, 
apart from "Python secretly tries to run just as slow on everything". 
Even slow, inefficient code will run faster on faster hardware. But how 
much faster? How accurate are your timing measurements?

Some possible explanations:

- the method you used to time the code is inaccurate or doesn't measure 
what you think it does;

- the code you have written spends most of its time doing things that 
aren't sped up by a faster computer, e.g. waiting for human input, 
downloading data from the Internet, reading and writing to a network 
drive, etc.;

- the benchmarks that say the second computer is 1000 times faster than 
the first are bogus (not necessarily lying, although possibly lying by 
ommission).

I expect that the anwser to this mystery is a combination of the first 
and the last factors. It's harder to measure the execution speed of code 
than you might think, and most PC benchmarks are worse than you might 
think. Many benchmarks are artifical and designed as advertising, to 
show the product in the best possible light. If a machine has a CPU 
clock speed that is 1000 times faster than the last model, the 
benchmarks will all be for tiny little programlets that are reliant on 
CPU speed. Meanwhile, the fact that real-world applications see hardly 
any benefit because the computer can't push data into and out of the CPU 
any faster than before gets conveniently swept under the carpet.

(Cynical? Who, me?)


-- 
Steven


More information about the Tutor mailing list