#!/usr/bin/env python3

import functools


def cached(f):
    """A simple caching decorator for instance functions not taking any arguments"""

    @functools.wraps(f)
    def g(self):
        if not hasattr(self, "__cache"):
            self.__cache = dict()
        if f not in self.__cache:
            self.__cache[f] = f(self)
        return self.__cache[f]

    return g

@@ -370,8 +370,483 @@
 eturn g%0A
+%0A%0Adef named_cached(name):%0A    %22%22%22A decorator allowing for specifying the name of a cache, allowing it to be modified elsewhere.%22%22%22%0A    def named_cached_decorator(f):%0A        @functools.wraps(f)%0A        def g(self):%0A            if not hasattr(self, %22__cache%22):%0A                self.__cache = dict()%0A            if name not in self.__cache:%0A                self.__cache%5Bname%5D = f(self)%0A            return self.__cache%5Bname%5D%0A%0A        return g%0A%0A    return named_cached_decorator%0A

Add named cache decorator