@memoize
def lev(s, t):
    len_s, len_t = len(s), len(t)
if len_s == 0:
    return len_t
if len_t == 0:
    return len_s
cost = 0 if s[-1] == t[-1] else 1
return min(lev(s[:-1], t) + 1, lev(s, t[:-1]) + 1, lev(s[:-1], t[:-1]) + cost)
s = 'Lorem ibsum +++'
t = 'Loren ipsum ...'
print(lev(s, t))
Maximum recursion depth exceeded, but only when using a decorator