How can I make this piece of code even faster?

Chris Angelico rosuav at
Sun Jul 21 11:21:52 CEST 2013

On Sun, Jul 21, 2013 at 5:11 PM, Paul Rudin <paul.nospam at> wrote:
> Steven D'Aprano <steve+comp.lang.python at> 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
>> effective.
> 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.

I haven't analyzed every suggestion in this thread in detail, but I
don't think any of them affects the algorithmic complexity of the
code. They're all incremental changes.


More information about the Python-list mailing list