4 ms·
Yes, see here: http://www.haskell.org/haskellwiki/Memoization http://www.haskell.org/haskellwiki/Memoization Note that in Python, you also have the issue that
by albertzeyer 12y ago
Yes, see here: http://www.haskell.org/haskellwiki/Memoization http://www.haskell.org/haskellwiki/Memoization
Note that in Python, you also have the issue that you still need to specify some cleverness about how long something is stored and what is stored. Many example memoize implementations just store everything (e.g.: https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize) but of course that is not a solution in practice.
- gizmo686 12y agoI don't think the methods mentioned in the haskell wiki are quite equivelent to the python decorator, as they require you to modify the data structure itself to support memoization. It should be possible to use UnsafePerformIO to create a generic function memoize function (at least for inputs that implelemt Eq or Ord), but that is almost definantly overkill and asking for space leaks.