Skip to main content

Speed-up your code by automatically identifying functions that should use caching in your code!

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cachegenius-0.1.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page