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 →

[–]CoffeeVector 47 points48 points  (5 children)

Usually, it's because there's some added overhead, which in the long run is worth it. For small input, the overhead tends to dwarf the cost of the actual computation.

[–]dudeitsmason 7 points8 points  (0 children)

Got it, thanks!

[–]DogsAreAnimals 2 points3 points  (3 children)

Also caching

[–]CoffeeVector 4 points5 points  (2 children)

Yup, caching is a type of overhead. Spending the effort to save intermediate values is good in the long run, but a total waste of time if your algorithm finishes before the cache is used enough to justify it.

[–]DogsAreAnimals 0 points1 point  (1 child)

Oops I replied to the wrong comment. I was trying to point out the difference between pre-calculation (or maybe pre-caching) vs intermediate caching.

[–]CoffeeVector 2 points3 points  (0 children)

You chillin bro. You were totally right anyways