cache_translation#

astro_metadata_translator.cache_translation(func, method=None)#

Cache the result of a translation method.

Parameters:
  • func (Callable) – Translation method to cache.

  • method (str, optional) – Name of the translation method to cache. Not needed if the decorator is used around a normal method, but necessary when the decorator is being used in a metaclass.

Returns:

wrapped – Method wrapped by the caching function.

Return type:

Callable

Notes

Especially useful when a translation uses many other translation methods or involves significant computation. Should be used only on to_x() methods.

@cache_translation
def to_detector_num(self):
    ....