Skip to content

rdghosal/memoirs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

memoirs

Because built in Rust must mean it's blazingly fast... right?


Description

Rust that compiles into a Python package that offers simple in-memoiry caching... or is it more like memoirization? 🤔 (Okay, I'll stop.)

import memoirs

@memoirs.Cache
def my_fancy_func(*args) -> str:
    print('running') 
    return ' '.join(str(a) for a in args)

Once a function return is memoized, subsequent invocations return a cached result without running the function again.

>>> my_fancy_func('Hello', 'World!') 
running
'Hello World!'

>>> my_fancy_func('Hello', 'World!') 
'Hello World!'

For something more interesting (well, if you like basic arithmetic), take a look at this example.


Installation

To play around with it (please don't use this in prod):

1. Set up a virtual environment and install maturin

$ python -m venv .venv
$ source .venv/bin/activate
$ pip install maturin

2. Install a dev version of the package into your virtual environment

$ maturin develop

There. Good to go.


But, how?

This project is made possible by pyo3. Check 'em out!!

About

PyO3 test project that creates a simple in-memory cache using a Python dict object

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages