summaryrefslogtreecommitdiff
path: root/performance_opt/cache
diff options
context:
space:
mode:
Diffstat (limited to 'performance_opt/cache')
-rw-r--r--performance_opt/cache/__init__.py0
-rw-r--r--performance_opt/cache/cache_demo.py21
2 files changed, 21 insertions, 0 deletions
diff --git a/performance_opt/cache/__init__.py b/performance_opt/cache/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/performance_opt/cache/__init__.py
diff --git a/performance_opt/cache/cache_demo.py b/performance_opt/cache/cache_demo.py
new file mode 100644
index 0000000..aa5b28c
--- /dev/null
+++ b/performance_opt/cache/cache_demo.py
@@ -0,0 +1,21 @@
+
+from functools import lru_cache
+import functools
+
+
+@lru_cache(256)
+def fib(n):
+ if n <= 1:
+ return n
+ return fib(n-1) + fib(n-2)
+
+
+
+
+if __name__ == '__main__':
+ print(functools._make_key((4, 6), {}, False))
+ print(fib(5))
+ print(fib.cache_info())
+
+ d = {object()}
+ \ No newline at end of file