Switch from copypasta'd memoize to functools32's lru_cache