Skip to content

🧞‍♂️ Speed-up your code by automatically identifying functions that should use caching in your code!

Notifications You must be signed in to change notification settings

NicolasMICAUX/cachegenius

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Stargazers Issues PyPi version Python 3


Logo

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().

(back to top)

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/YourAmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Authors

This library was created by Nicolas MICAUX.
You might also be interested by work from RobustPy

About

🧞‍♂️ Speed-up your code by automatically identifying functions that should use caching in your code!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published