How can I make this piece of code even faster?
paul.nospam at rudin.co.uk
Sun Jul 21 09:11:59 CEST 2013
Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
> On Sat, 20 Jul 2013 13:22:03 -0700, pablobarhamalzas asked:
> "How can I make this piece of code even faster?"
> - Use a faster computer.
> - Put in more memory.
> - If using Unix or Linux, decrease the "nice" priority of the process.
> I mention these because sometimes people forget that if you have a choice
> between "spend 10 hours at $70 per hour to optimize code", and "spend
> $200 to put more memory in", putting more memory in may be more cost
Sure - but it's helpful if programmers understand a little bit about the
computational complexity of algorithms. If it's just a question of
making each basic step of your algorithm a bit faster, then it may well
be better to spend money on better hardware than on squeezing more out
of your code. OTOH if you've got an n^2 implementation and there's
actually an n.log n solution available then you should probably re-code.
Of course if what you've got is actually adequate for your use-case then
it maybe that you don't actually need to do anything at all...
More information about the Python-list