Balanced trees

Chris Angelico rosuav at gmail.com
Mon Mar 10 21:45:52 EDT 2014


On Tue, Mar 11, 2014 at 12:26 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> In my experience, the average developer has an amazing talent for
> pessimising code when they think they are optimising it.

I remember a number of incidents from personal experience when I was a
*very* average developer. One time, writing C++ code, I looked at the
disassembly and decided the compiler was doing a terrible job. No no,
I could make this so much better by using the 80x86 "REP MOVSW"
command (or commands, depending on your point of view). That would be
so much better than all those separate operations the silly compiler
was doing! Roughly an hour of fiddling later, making sure it all still
worked correctly, I discover that... hmm, it's not actually any
faster. Turns out the 80x86 string opcodes are really inefficient;
they're short (a one-byte command that says "read a
byte/word/doubleword from DS:SI, write it to ES:DI, and increment or
decrement SI and DI"), but not fast. In my defense, I at least did
measure before-and-after, and learned that I should back out that
change :)

ChrisA



More information about the Python-list mailing list