It is, but memoisation has the specific meaning of caching the result of an (expensive) pure function, like factorisation. To me the difference is that a memoised result can never be wrong and you only have to consider the memory impact, whereas caching implies that the result may become out of date if you hold it for too long, e.g. get the comments on this reddit post.
My previous job had a very nice memoization decorator that you could apply to arbitrary functions in python. Of course, it evolved to be a generic caching mechanism and had settings for (1) expiring memoized results after a timeout, (2) memoizing based on only some of the function inputs (e.g., memoize based on the parameters and not the database handle that you passed in), (3) limiting the total size of memoized objects, &c.
View all comments
Show parent comment
23
u/elingeniero 1d ago
It is, but memoisation has the specific meaning of caching the result of an (expensive) pure function, like factorisation. To me the difference is that a memoised result can never be wrong and you only have to consider the memory impact, whereas caching implies that the result may become out of date if you hold it for too long, e.g. get the comments on this reddit post.