Idiom for running compiled python scripts?

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sat Mar 24 23:40:33 EDT 2007


On Sat, 24 Mar 2007 22:59:06 +0000, Mark wrote:

>> I timed it against running plain .py and running .pyc directly. It
>> seemed to be roughly on par with running .pyc directly, and about 18ms
>> faster than running .py. The file had 600 lines (21kb) of code.
> 
> So see my point at least? I'm still not sure why this approach is
> ill-favoured?

Because this is entirely a trivial saving. Who cares? Sheesh.

That's less than the natural variation in execution speed caused by (e.g.)
network events on your PC. I've just run the same do-nothing script (a
simple "pass") three times, and got times of 338ms, 67ms and 74ms. That's
a variation of 271 milliseconds between runs of the same script, and you
care about 18ms???

Saving 18ms on a script that takes 50ms to execute *might* be worthwhile,
if you're using that script in an automated system that executes it
thousands of times. If you're calling it by hand, come on now, you're not
even going to notice the difference! 50ms is close enough to instantaneous
that 32ms is not detectably faster to the human eye.

If you save 18ms one thousand times a day, you save a grand total of ...
eighteen seconds. Wow. Now you can spend more time with your family.

As of 2005, the world's fastest typist Barbara Blackburn has been clocked
at a peak of 212 words per minute for short bursts. Assuming an average of
five key strokes per word (including the space) that's about 18 key
presses per second, or 55 milliseconds per key press. A more realistic
figure for the average professional typist is about six key presses per
second, or 160 milliseconds per key press, and that's for pure
transposition (copying). If you've got to think carefully about what
you're typing, like sys admins do, the average time per key press is
significantly larger.

In other words, unless you can save AT LEAST 160 milliseconds, it isn't
worth typing even one more character. If you have to type one extra
character to save 18ms, you're actually 140ms worse off.

I can't believe the number of people who are spending this amount of time
worrying about such a trivial saving, and I can't believe that I've let
myself be suckered into this discussion. Don't you people have lives???



-- 
Steven
who has no life, which is why he is spending time complaining about people
who have no lives.




More information about the Python-list mailing list