aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/compat/functools.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-05-20 20:55:21 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-05-20 21:06:37 +0530
commit2762dbb17e8556140f9fff0c0aa3373c521f5e09 (patch)
tree75be40e22610ba1648a1b503fdff803bb2c4f8fb /yt_dlp/compat/functools.py
parent666c36d58dfacc8998952569cc2d9c414957c53d (diff)
downloadhypervideo-pre-2762dbb17e8556140f9fff0c0aa3373c521f5e09.tar.lz
hypervideo-pre-2762dbb17e8556140f9fff0c0aa3373c521f5e09.tar.xz
hypervideo-pre-2762dbb17e8556140f9fff0c0aa3373c521f5e09.zip
[compat] Add `functools.cached_property`
Diffstat (limited to 'yt_dlp/compat/functools.py')
-rw-r--r--yt_dlp/compat/functools.py12
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__)