memoi


Namememoi JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/emanuel-schmid/memoi
Summaryprovides generic methods to memoize function and method calls
upload_time2024-02-28 14:26:29
maintainer
docs_urlNone
authorEmanuel Schmid
requires_python>=3.10
licenseGPL-3
keywords memoization cache
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =====
Memoi
=====

Description
===========

A generic caching mechanism for memoizing function or method calls.

Prerequisites
=============

- Python >= 3.10

Installation
============

.. code-block:: bash

  python -m pip install memoi


Example
=======

.. code-block:: python

  from datetime import datetime as dt
  from memoi import cached, TextFileRepo

  @cached(TextFileRepo('.'))
  def f(*args, **kwargs):
      return f"this is the result of the first f() call at {dt.now().isoformat()}"

  print(f())
  print(f())


This will create a a sqlite database ``memo.sqlite``, keeping track of function calls,
and a text file ``50/506f353d3ef92d51f3e57bae99367caf`` directory, containing the result of the first ``f()`` call.
Obviously the timestamp from the first function call is preserved. 

Author
======

Emanuel Schmid, schmide@ethz.ch

=========
Changelog
=========

Release 0.0.1
=============

Description
-----------

Minimum Viable Product of a result caching function decorator.

Added
-----

- decorator ``cached``: providing a caching mechanism for return values, so the function is not executed the next time when it is called with the same arguments.
- class ``TextFileRepo``: for caching return values of functions returning strings as text files in a configurable directory.

Release 0.1.0
=============

Description
-----------

Multi-String support.

Changed
-------

- ``cached``: returns a pair of datetime and original result, the former indicating the date of first submission; can handle functions/methods that return iterables.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/emanuel-schmid/memoi",
    "name": "memoi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "memoization,cache",
    "author": "Emanuel Schmid",
    "author_email": "schmide@ethz.ch",
    "download_url": "",
    "platform": null,
    "description": "=====\r\nMemoi\r\n=====\r\n\r\nDescription\r\n===========\r\n\r\nA generic caching mechanism for memoizing function or method calls.\r\n\r\nPrerequisites\r\n=============\r\n\r\n- Python >= 3.10\r\n\r\nInstallation\r\n============\r\n\r\n.. code-block:: bash\r\n\r\n  python -m pip install memoi\r\n\r\n\r\nExample\r\n=======\r\n\r\n.. code-block:: python\r\n\r\n  from datetime import datetime as dt\r\n  from memoi import cached, TextFileRepo\r\n\r\n  @cached(TextFileRepo('.'))\r\n  def f(*args, **kwargs):\r\n      return f\"this is the result of the first f() call at {dt.now().isoformat()}\"\r\n\r\n  print(f())\r\n  print(f())\r\n\r\n\r\nThis will create a a sqlite database ``memo.sqlite``, keeping track of function calls,\r\nand a text file ``50/506f353d3ef92d51f3e57bae99367caf`` directory, containing the result of the first ``f()`` call.\r\nObviously the timestamp from the first function call is preserved. \r\n\r\nAuthor\r\n======\r\n\r\nEmanuel Schmid, schmide@ethz.ch\r\n\r\n=========\r\nChangelog\r\n=========\r\n\r\nRelease 0.0.1\r\n=============\r\n\r\nDescription\r\n-----------\r\n\r\nMinimum Viable Product of a result caching function decorator.\r\n\r\nAdded\r\n-----\r\n\r\n- decorator ``cached``: providing a caching mechanism for return values, so the function is not executed the next time when it is called with the same arguments.\r\n- class ``TextFileRepo``: for caching return values of functions returning strings as text files in a configurable directory.\r\n\r\nRelease 0.1.0\r\n=============\r\n\r\nDescription\r\n-----------\r\n\r\nMulti-String support.\r\n\r\nChanged\r\n-------\r\n\r\n- ``cached``: returns a pair of datetime and original result, the former indicating the date of first submission; can handle functions/methods that return iterables.\r\n",
    "bugtrack_url": null,
    "license": "GPL-3",
    "summary": "provides generic methods to memoize function and method calls",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/emanuel-schmid/memoi"
    },
    "split_keywords": [
        "memoization",
        "cache"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "096c95cca586d1bfade73ef7305cd94b9608ad2823afb4b2903239c4bda92a91",
                "md5": "77e19784bb9990c542fc95ab0755f0c5",
                "sha256": "8b6867bf896f46ab3be5f6ebe4b49c5b268a8f8092e2c5a508fbc37e4c174c91"
            },
            "downloads": -1,
            "filename": "memoi-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "77e19784bb9990c542fc95ab0755f0c5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 16457,
            "upload_time": "2024-02-28T14:26:29",
            "upload_time_iso_8601": "2024-02-28T14:26:29.890179Z",
            "url": "https://files.pythonhosted.org/packages/09/6c/95cca586d1bfade73ef7305cd94b9608ad2823afb4b2903239c4bda92a91/memoi-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-28 14:26:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "emanuel-schmid",
    "github_project": "memoi",
    "github_not_found": true,
    "lcname": "memoi"
}
        
Elapsed time: 0.18806s