Example #1
0
    def _lazyprop(self):
        if scopes.dpp_scope_active():
            attr_name = '_lazy_dpp_' + func.__name__
        else:
            attr_name = '_lazy_' + func.__name__

        try:
            return getattr(self, attr_name)
        except AttributeError:
            setattr(self, attr_name, func(self))
        return getattr(self, attr_name)
Example #2
0
    def _compute_once(self, *args, **kwargs):
        if scopes.dpp_scope_active():
            attr_name = '_compute_once_dpp_' + func.__name__
        else:
            attr_name = '_compute_once_' + func.__name__

        try:
            return getattr(self, attr_name)
        except AttributeError:
            setattr(self, attr_name, func(self, *args, **kwargs))
        return getattr(self, attr_name)
Example #3
0
def _cache_key(args, kwargs):
    key = args + tuple(list(kwargs.items()))
    if scopes.dpp_scope_active():
        key = ('__dpp_scope_active__', ) + key
    return key
Example #4
0
 def is_constant(self) -> bool:
     if scopes.dpp_scope_active():
         return False
     return True
def _cache_key(args, kwargs):
    key = args + tuple([(key, item) for key, item in kwargs.items()])
    if scopes.dpp_scope_active():
        key = ('__dpp_scope_active__', ) + key
    return key