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?
20
Upvotes
View all comments
3
u/Aggressive_Ad_5454 May 28 '25
Any deterministic function (for which its output depends only on its inputs) is idempotent.
This idempotency dealio only matters for operations with side-effects. It would be silly, practically speaking, to memoize an operation with a side effect.