cache_translation

astro_metadata_translator.cache_translation(func: Callable, method: str | None = None) Callable

Cache the result of a translation method.

Parameters:
funcCallable

Translation method to cache.

methodstr, 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:
wrappedCallable

Method wrapped by the caching function.

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):
    ....