Backport of functools.lru_cache from Python 3.3.