r/computerscience • u/dashdanw • May 27 '25
Discussion Does memoizing a function make it truly "idempotent"?
If you cache the result of a function, or say, for instance, check to see if its already been run, and skipping running it a second time make a function truly idempotent?
21
Upvotes
View all comments
Show parent comment
1
u/SirClueless May 28 '25
Why is it silly to memoize a function with a side effect? It's effectively using a bit of memory to remember that you've performed the side effect. There are plenty of cases where that's a useful and sensible thing to do.