Currently, parameters are recalculated from scratch on each access. This is pretty wasteful, especially if a lot of calculation goes into the parameter (e.g. expensive cast function). Since parameters aren't really meant to be dynamic, I think it might make sense to always cache values after load(). I would want to have the option to disable the cache on a per-param basis.
Some pseudo-code:
def load(obj):
...
get_meta(obj).cache_version += 1
...
class param:
def __init__(self, ..., dynamic=False, ...):
self.dynamic = False
self.cache_version = -1
def __get__(self, obj):
meta = get_meta(obj)
if self.cache_version == meta.cache_version and not self.dynamic:
return self.cache_value
else:
...
self.cache_version = meta.cache_version
Currently, parameters are recalculated from scratch on each access. This is pretty wasteful, especially if a lot of calculation goes into the parameter (e.g. expensive cast function). Since parameters aren't really meant to be dynamic, I think it might make sense to always cache values after
load()
. I would want to have the option to disable the cache on a per-param basis.Some pseudo-code: