remove dependency on memoized

memoized uses cPickle internally which is a Python 2-only package. Since
memoization is a fairly simple thing to implement directly, do so.