Package: klepto
About Kleptokleptoextends Python’slru_cacheto utilize different keymaps and
alternate caching algorithms, such aslfu_cacheandmru_cache.
While caching is meant for fast access to saved results,kleptoalso
has archiving capabilities, for longer-term storage.kleptouses a
simple dictionary-sytle interface for all caches and archives, and all
caches can be applied to any Python function as a decorator. Keymaps
are algorithms for converting a function’s input signature to a unique
dictionary, where the function’s results are the dictionary value.
Thus fory = f(x),ywill be stored incache[x](e.g.{x:y}).kleptoprovides both standard and“safe”caching, where“safe”caches
are slower but can recover from hashing errors.kleptois intended
to be used for distributed and parallel computing, where several of
the keymaps serialize the stored objects. Caches and archives are
intended to be read/write accessible from different threads and
processes.kleptoenables a user to decorate a function, save the
results to a file or database archive, close the interpreter,
start a new session, and reload the function and it’s cache.kleptois part ofpathos, a Python framework for heterogeneous computing.kleptois in active development, so any user feedback, bug reports, comments,
or suggestions are highly appreciated.  A list of issues is located athttps://github.com/uqfoundation/klepto/issues, with a legacy list maintained athttps://uqfoundation.github.io/project/pathos/query.Major Featureskleptohas standard and“safe”variants of the following:lfu_cache- the least-frequently-used caching algorithmlru_cache- the least-recently-used caching algorithmmru_cache- the most-recently-used caching algorithmrr_cache- the random-replacement caching algorithmno_cache- a dummy caching interface to archivinginf_cache- an infinitely-growing cachekleptohas the following archive types:file_archive- a dictionary-style interface to a filedir_archive- a dictionary-style interface to a folder of filessqltable_archive- a dictionary-style interface to a sql database tablesql_archive- a dictionary-style interface to a sql databasehdfdir_archive- a dictionary-style interface to a folder of hdf5 fileshdf_archive- a dictionary-style interface to a hdf5 filedict_archive- a dictionary with an archive interfacenull_archive- a dictionary-style interface to a dummy archivekleptoprovides the following keymaps:keymap- keys are raw Python objectshashmap- keys are a hash for the Python objectstringmap- keys are the Python object cast as a stringpicklemap- keys are the serialized Python objectkleptoalso includes a few useful decorators providing:simple, shallow, or deep rounding of function argumentscryptographic key generation, with masking of selected argumentsCurrent ReleaseThe latest released version ofkleptois available from:https://pypi.org/project/kleptokleptois distributed under a 3-clause BSD license.Development VersionYou can get the latest development version with all the shiny new features at:https://github.com/uqfoundationIf you have a new contribution, please submit a pull request.Installationkleptocan be installed withpip:$ pip install kleptoTo include optional archive backends, such as HDF5 and SQL, in the install:$ pip install klepto[archives]To include optional serializers, such asjsonpickle, in the install:$ pip install klepto[crypto]Requirementskleptorequires:python(orpypy),>=3.8setuptools,>=42dill,>=0.3.8pox,>=0.3.4Optional requirements:h5py,>=2.8.0pandas,>=0.17.0sqlalchemy,>=1.4.0jsonpickle,>=0.9.6cloudpickle,>=0.5.2More InformationProbably the best way to get started is to look at the documentation athttp://klepto.rtfd.io. Also seeklepto.testsfor a set of scripts that
test the caching and archiving functionalities inklepto.
You can run the test suite withpython-mklepto.tests.  The
source code is also generally well documented, so further questions may
be resolved by inspecting the code itself. Please feel free to submit
a ticket on github, or ask a question on stackoverflow (@Mike McKerns).
If you would like to share how you usekleptoin your work, please send
an email (tommckerns at uqfoundation dot org).CitationIf you usekleptoto do research that leads to publication, we ask that you
acknowledge use ofkleptoby citing the following in your publication:Michael McKerns and Michael Aivazis,
"pathos: a framework for heterogeneous computing", 2010- ;
https://uqfoundation.github.io/project/pathosPlease seehttps://uqfoundation.github.io/project/pathosorhttp://arxiv.org/pdf/1202.1056for further information.