News for hackers. Stuff that matters.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by currymj on Sunday April 25, 2021 @12:29PM (#26933988)
it is a particular part of the Python 3 standard library. it is one extra line of code to automatically memoize a recursive function.

you just do:

    from functools import lru_cache
    
    @lru_cache(maxsize=None)
    def brute_recursive_func(x):
        ...
And you're good to go.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by rmk on Sunday April 25, 2021 @02:49PM (#26935404)
Very nice! I often forget this handy thing during interviews. Good thing to impress your interviewer with :)
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by rmk on Tuesday April 27, 2021 @11:28AM (#26957239)
One thing of note: The arguments to the method you are memoizing need to be hashable. For example, if you want to memoize a method call whose parameters include a list, you will get an error!