Speed-up your code by automatically identifying functions that should use caching!
View Demo
·
Report Bug
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!
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
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()
.
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
This library was created by Nicolas MICAUX.
You might also be interested by work from RobustPy