Speed-up your code by automatically identifying functions that should use caching in your code!
Project description
CacheGenius
Speed-up your code by automatically identifying functions that should use caching!
View Demo
·
Report Bug
About The Project
Have you ever spent hours trying to speed up some code, only to finally realize you're computing the same things 2 or 3 times, which means some caching does the trick ? What a waste of time !
🧞♂️ CacheGenius automatically identifies functions that should use caching in your code, so you can speed-up your code effortlessly!
Getting Started
Using CacheGenius is very simple.
Install CacheGenius with pip :
pip install cachegenius
To analyse an entire module mypackage
, with all the functions and methods it contains, add this lines at the begginning of your code:
import mypackage
import cachegenius
cachegenius(mypackage)
Now, use your module functions as usual. CacheGenius will automatically analyze all the functions you call, and will tell you if you should use caching or not.
>>> cachegenius.report()
Function: mokemodule.mokescript.my_func
Should cache: True
Advanced usage
You can use the different parameters of cachegenius.report()
to change the temporary files path, and print more infos using debug
.
Two parameters are available to tune the cost of computing and memory, that are used to decide if caching is worth it or not.
def report(
autocache_path: str = "cachegenius_data/",
debug: bool = True,
cost_per_comput_hr: float = 0.1, # $/hr
cost_per_mem_gb: float = 0.2 # $/gb
)
You can clean all temporary files with cachegenius.empty()
.
How to contribute
Contributing is an awesome way to learn, inspire, and help others. Any contributions you make are greatly appreciated, even if it's just about styling and best practices.
If you have a suggestion that would make this project better, please fork the repo and create a pull request.
Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/YourAmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Authors
This library was created by Nicolas MICAUX.
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
File details
Details for the file cachegenius-0.1.0.tar.gz
.
File metadata
- Download URL: cachegenius-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77613f0d22f2c70a773984a7c53d8ff3b25f5e4a0577d9fe66ec6ff46aab0ec1 |
|
MD5 | 0a06b9a000f5fda2609e09cf4f653fcf |
|
BLAKE2b-256 | 68df367cf68cdc0caf1b62515b132d0bf72e45ec11b8baab0a43c1065f740430 |