Skip to main content

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.

Metadata

Release files for cachegenius 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cachegenius 0.1.0
File Size Uploaded
cachegenius-0.1.0.tar.gz 6.0 kB Details

Release files / cachegenius-0.1.0.tar.gz

Download URL cachegenius-0.1.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
77613f0d22f2c70a773984a7c53d8ff3b25f5e4a0577d9fe66ec6ff46aab0ec1
BLAKE2b-256 checksum
How to use checksums
68df367cf68cdc0caf1b62515b132d0bf72e45ec11b8baab0a43c1065f740430
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page