Remove cachetools, add chash and xxhash dependencies, use chash method memoization decorator in pattern.py.