Get the latest tech news
The intricacies of implementing memoization in Ruby
A long time ago, I wrote a memoization library for Ruby. It was not easy, but I learned a great deal in the process. In this article, I am share these learnings and showing you how deep the memoization rabbit hole goes.
This is a more accurate way than using Time.now, because the monotonic clock is not affected by small shifts that occur e.g. when synchronising with a network time server. In Ruby, method definitions return the mehod name as a symbol, so memoize can be stuck in front of the def keyword and the memoize :fib line removed: Unfortunately, in the excitement of finding an approach to support memoization for frozen objects, a bigger problem has appeared: memory usage.
Or read this on Hacker News