

Summing Up - a Tale of Code Optimisation (TCO) - RiderOfGiraffes
http://www.solipsys.co.uk/Writings/SummingUp.html

======
jacquesm
Why would you spend so much time on writing and optimizing the hand coded
version of 'sum' instead of simply upgrading your version of python on that
system, which would take only a few minutes at worst?

The built-in sum would outperform that loop quite handily I would imagine.

~~~
RiderOfGiraffes
My direct personal experience - as attested by the guys I work with - is that
upgrading something like Python, or a browser, breaks my machine for up to a
week as I fight through dependency hell.

The machine is running SuSE 8.1 with a broken YaST. Upgrading Python - I
suspect - would require upgrading all the C libraries, _etc._ Easier just to
wipe that machine and start from scratch, but why bother? This was just a
trivial play on the side.

~~~
jacquesm
chroot is your friend in such cases.

~~~
RiderOfGiraffes
But then I would never have had the fun of exploring these different versions
of a classic algorithm.

There's a bigger point about your comment though. I've learned through
painful, painful experience to be wary of people who say "Why not just ..." It
usually hides a weath of knowledge and experience that they take for granted,
but which takes time to accrue. Upgrading Python might just take half a day,
or it might take a week. How do I know in advance what that would be? How do I
know that in the middle of it I'll still have a usable machine at all for
stuff I need to be doing?

There's the old saw about stopping to sharpen the axe because, in the long
run, it'll be quicker. I'm always very aware of that. I've found that trying
to "sharpen the axe" by way of "upgrading" my machine _always_ ends up costing
far more time than it saved.

Your experience will no doubt be different, but your knowledge base is
different from mine. There are swathes of things I don't know, don't have time
to explore, and don't really care about.

In truth, I wrote the versio that blew the stack, played around for 30 minute
because it was interesting, took a break, then wrote the obvious final
version.

Time well spent, and certainly more fun that upgrading Python. (On that
machine).

~~~
jacquesm
Oh, I agree about the fun part :)

But when you're optimizing something that usually indicates you would like to
have your results faster! ;)

Dependency hell is one of the bigger shortcomings of the way software is
distributed, my way of dealing with that is to link against static libraries
or use that chroot. For most packages static linking is a compile time flag.

Typically though, compiling from source should work, it's when you start
upgrading from binaries in older repositories that the trouble starts.

