r/ProgrammerHumor • • 1d ago

Meme dynamicProgramming

Post image
5.3k Upvotes

140 comments sorted by

View all comments

Show parent comment

1

u/guyblade 13h ago

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.

I guess nothing can stay pure.

1

u/elingeniero 10h ago

lru_cache ?