diff options
Diffstat (limited to 'yt_dlp/compat/functools.py')
-rw-r--r-- | yt_dlp/compat/functools.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/yt_dlp/compat/functools.py b/yt_dlp/compat/functools.py index 36c983642..c3c4d8f48 100644 --- a/yt_dlp/compat/functools.py +++ b/yt_dlp/compat/functools.py @@ -10,3 +10,15 @@ try: cache # >= 3.9 except NameError: cache = lru_cache(maxsize=None) + +try: + cached_property # >= 3.8 +except NameError: + class cached_property: + def __init__(self, func): + update_wrapper(self, func) + self.func = func + + def __get__(self, instance, _): + setattr(instance, self.func.__name__, self.func(instance)) + return getattr(instance, self.func.__name__) |