From: Neil Smith <neil.git@njae.me.uk>
Date: Sun, 3 Nov 2013 11:42:51 +0000 (+0000)
Subject: Now using the built-in functools.lru_cache instead of my own memo function
X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=2985cc355e868951a2755be23d3503b05ba17ea7;p=cipher-tools.git

Now using the built-in functools.lru_cache instead of my own memo function
---

diff --git a/segment.py b/segment.py
index 08bc0aa..712895b 100644
--- a/segment.py
+++ b/segment.py
@@ -4,19 +4,10 @@ import collections
 from math import log10
 import itertools
 import sys
+from functools import lru_cache
 sys.setrecursionlimit(1000000)
 
-def memo(f):
-    "Memoize function f."
-    table = {}
-    def fmemo(*args):
-        if args not in table:
-            table[args] = f(*args)
-        return table[args]
-    fmemo.memo = table
-    return fmemo
-
-@memo
+@lru_cache()
 def segment(text):
     """Return a list of words that is the best segmentation of text.
     """