Cache functions to speed up recursion
Project description
recache
Cache functions to speed up recursion
install
From Pypi:
python -m pip install recache
From GitHub:
python -m pip install git+https://github.com/donno2048/recache
Usage
from recache import cache
def fib(n): # slow recursion
if n < 0: return None
if n <= 1: return 1
return fib(n - 1) + fib(n - 2)
@cache
def cfib(n): # fast recursion
if n < 0: return None
if n <= 1: return 1
return cfib(n - 1) + cfib(n - 2)
To see the exact timing see The notebook
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
recache-1.0.0.tar.gz
(1.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file recache-1.0.0.tar.gz.
File metadata
- Download URL: recache-1.0.0.tar.gz
- Upload date:
- Size: 1.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
245e613d8bfb7b684b68ca33bb3092da994ff9634b16f5cbdb859fcbdd7257cd
|
|
| MD5 |
379b44e3030d53e50d563fe3b3a32aec
|
|
| BLAKE2b-256 |
ef813058a299ff4a6da8aa73450e3eaf2121e41e0edb6ccd829166a4141cec9e
|
File details
Details for the file recache-1.0.0-py3-none-any.whl.
File metadata
- Download URL: recache-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f2d38ed3d2ecbab658802fee48e608a06c2cd478246d8ce157785055d7763b6
|
|
| MD5 |
735c4b742e8057cd94d9ee87415610f9
|
|
| BLAKE2b-256 |
c265ca407bcbc279d5738e8c9fc9e88117546cb6e6e6b4684f1bcdeec619e2af
|