Idiom for running compiled python scripts?

Steven D'Aprano steve at REMOVEME.cybersource.com.au
Thu Mar 22 23:03:12 EDT 2007


On Fri, 23 Mar 2007 01:01:15 +0000, Mark wrote:

> So given the lack of response it seems that there is probably no such
> idiom and that I should not be concerned by the inefficiency inherent in
> running .py scripts directly?
> 
> I did some time tests and sure, the speed gain is slight, but it is a 
> gain none the less.

Since you've done these tests already, perhaps you can tell us what gain
you actually got?

Here's a test I did:

[steve at apple ~]$ time python script.py
the result is 166166000

real    0m0.555s
user    0m0.470s
sys     0m0.011s
[steve at apple ~]$ time python script.pyc
the result is 166166000

real    0m0.540s
user    0m0.456s
sys     0m0.011s


That gives me an absolute gain of 15ms which is a percentage gain of about
3%. But don't forget the time it takes you to type the extra "c" at the
end of the script, even with filename completion. The average human
reaction time is something between 200 and 270 milliseconds, so unless
you're saving at least 200ms, typing that extra "c" at the end actually
wastes time.

Of course you have to type the "c". You're not deleting the source files
away are you? *wink*



-- 
Steven D'Aprano 




More information about the Python-list mailing list