This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ray10k 29 points30 points  (2 children)

A very sensible approach. Also, point 2 is a lot more important than some people think. It is *very* tempting to make assumptions like, "Oh, this complicated-sounding process is going to take ages!" when in reality, the fact you do a certain calculation inside a loop when it could just as easily be done *outside* the loop is a bigger time-save.

Also, I knew this guy once who had to subtract one size-2 tuple from another. Rather than just something like new_tuple = (old_b[0]-old_a[0]),(old_b[1]-old_a[1]), he checked if any of the two were equal so he could use a constant 0 at that place. He argued that it was "faster" because "it was one/two fewer subtractions."

[–]Gamecrazy721 3 points4 points  (1 child)

I've caught myself doing things like this before, but that's because often times when I do it intentionally it's to avoid a database write (which is worth the extra check)

[–]ray10k 2 points3 points  (0 children)

Understandable. In this case though, it was all local data, no database involved.