Idiom for running compiled python scripts?

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sun Mar 25 05:48:09 EDT 2007


On Sun, 25 Mar 2007 07:10:23 +0000, Mark wrote:

> On Sun, 25 Mar 2007 13:40:33 +1000, Steven D'Aprano wrote:
>> Because this is entirely a trivial saving. Who cares? Sheesh.
>> ...
>> Saving 18ms on a script that takes 50ms to execute *might* be
>> worthwhile, ...
> 
> I don't understand your attitude. Sure, we are talking slight savings in
> machine efficiency but I am sure the python developers have laboured
> many long hours on subtle optimisations of the virtual machine, many of
> which probably dwarf the issue discussed here. Tell them their work is
> trivial and unnecessary.

Why would I do that?

As you said yourself, their optimizations dwarf the trivial issue you
discuss. They, unlike you, grasp that the aim of optimization is to make
significant savings in meaningful places, not waste time making
insignificant savings in meaningless places.


> Every little bit helps. 

No it doesn't. Spending hours of effort to save 18 seconds a day is a
waste of both time and effort.

If you have a process that takes eight hours and 18 seconds to run, and
you need it to run in eight hours or less, then that 18 seconds is
absolutely critical. But how likely is that? Chances are nobody will care
if the process takes eight hours and ten minutes or seven minutes and
fifty minutes. Saving 18ms once at startup for a single script, or 18
seconds over the course of an entire day, pales into insignificance. 



> Why do I concern myself
> with this inefficiency - because it is there.

Fine fine -- except the hours you spend solving it is an inefficiency a
million times bigger than the one you are concerned with.

Okay, that's not fair -- it might take you hours to solve it once, but
from that moment on, you can save 18ms every time you run a script. In the
course of a day, you might save 18 seconds. In just 600 working days,
you'll have made that time back, and every 18ms after that is pure gain!

BFD.

Except, of course, that each time you type that one extra character, you
lose 160ms to gain 18ms. You're actually going backwards.

And that's the thing that demonstrates that for all your talk of
efficiency, you're not really interested in efficiency. If you were, you'd
do the maths and, having discovered that it costs you 160ms to save 18ms,
you're actually *less* efficient.


> Of course I realise the modern mantra that "premature optimisation is
> the root of all evil" but I don't subscribe to it. 

That's nice.

> Programmers have been
> "encouraged" to not give a toss about efficiency 

Blathering on about saving 18ms might make you feel good, but that's not
efficient. Making the code run 18ms faster at the expense of the total
process running 140ms slower is a pessimation, not an optimization.


-- 
Steven.




More information about the Python-list mailing list