def cachedproperty(func):
    """Decorator for cached property loading of class instances."""
    attr_name = func.__name__

    @property
    def cached(self):
        if not hasattr(self, '_cache'):
            setattr(self, '_cache', {})
        try:
            return self._cache[attr_name]
        except KeyError:
            result = self._cache[attr_name] = func(self)
            return result

    return cached