-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
When accessing an arbitrary time scale for a Time object, the internal object is always replicated. This came up in #4302.
def __getattr__(self, attr):
"""
Get dynamic attributes to output format or do timescale conversion.
"""
if attr in self.SCALES and self.scale is not None:
tm = self.replicate()
tm._set_scale(attr)
return tm
What about:
- Return
selfifattr == self.scale? - Cache other scales so getting both
jd1andjd2after transforming will be efficient?
Roughly:
def __getattr__(self, attr):
"""
Get dynamic attributes to output format or do timescale conversion.
"""
if attr in self.SCALES and self.scale is not None:
if attr == self.scale:
tm = self
elif attr in self._scale_cache:
tm = self._scale_cache[attr]
else:
tm = self.replicate()
tm._set_scale(attr)
self._scale_cache[attr] = tm
return tm