dyncache


Namedyncache JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/b10011/dyncache
SummaryDynamic input-output caching for deterministic functions
upload_time2025-01-02 10:35:52
maintainerNone
docs_urlNone
authorNiko Järvinen
requires_python<4.0,>=3.5
licenseMIT
keywords function cache dataset ai machine learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            **Dynamic input-output caching for deterministic functions**

|pypi| |docs| |license|

Features
========

* Keep It Simple, Stupid: A single decorator that does everything for you
* Automagically detects if the decorated function is changed and transparently
  updates cache accordingly without ever returning cached results of the old
  function.

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

:code:`pip3 install dyncache`

Examples
========

.. code:: python3
   
   # Import the class
   from dyncache import Cache
   # Alternatively you may use the lowercased name
   from dyncache import cache


   # Use with default options. It will create a file "circle_area.dyncache" into
   # the current directory.
   @Cache()
   def circle_area(radius):
       return 3.14159 * (radius ** 2)
       

   # Empty parentheses are not required for the decorator.
   @Cache
   def circle_area(radius):
       return 3.14159 * (radius ** 2)


   circle_area(2)  # Calculates and returns
   circle_area(3)  # Calculates and returns
   circle_area(2)  # Returns from cache


   # Saves the cache to /tmp/hello.world.
   @Cache(root="/tmp", filename="hello.world")
   def circle_area(radius):
       ...


   # Use for function with large input/output -values.
   @Cache(largeitems=True)
   def load_all_api_data_for_a_day(day):
       ...


   # When items are small and cache would update too often, setting autowrite to
   # False lets you control when the cached data is written to the file.
   cache = Cache(autowrite=False)
   @cache
   def really_frequent_function(a, b):
       ...
   ...
   cache.write()  # Write cache data to the file
   sys.exit(0)


Contributing
============

* Send any issues to GitHub's issue tracker.
* Before sending a pull request, format it with `Black`_ (-Sl79)
* Any changes must be updated to the documentation
* All pull requests must be tested with tox (if you are using pyenv, add the installed versions for py35-py38 and pypy3 to .python-version at the root of this repository before running tox)


.. _`Black`: https://github.com/psf/black

.. |pypi| image:: https://img.shields.io/pypi/v/dyncache.svg
    :alt: PyPI
    :target: https://pypi.org/project/dyncache/
.. |docs| image:: https://readthedocs.org/projects/dyncache/badge/?version=latest
    :alt: Read the Docs
    :target: http://dyncache.readthedocs.io/en/latest/
.. |license| image:: https://img.shields.io/github/license/b10011/dyncache.svg
    :alt: License
    :target: https://github.com/b10011/dyncache/blob/master/LICENSE

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/b10011/dyncache",
    "name": "dyncache",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.5",
    "maintainer_email": null,
    "keywords": "function, cache, dataset, ai, machine learning",
    "author": "Niko J\u00e4rvinen",
    "author_email": "nbjarvinen@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/63/06/47f072d2d098ce7ae4e0fc241d2cafc65e49168d6396e4c26c79c2194ed1/dyncache-0.1.2.tar.gz",
    "platform": null,
    "description": "**Dynamic input-output caching for deterministic functions**\n\n|pypi| |docs| |license|\n\nFeatures\n========\n\n* Keep It Simple, Stupid: A single decorator that does everything for you\n* Automagically detects if the decorated function is changed and transparently\n  updates cache accordingly without ever returning cached results of the old\n  function.\n\nInstallation\n============\n\n:code:`pip3 install dyncache`\n\nExamples\n========\n\n.. code:: python3\n   \n   # Import the class\n   from dyncache import Cache\n   # Alternatively you may use the lowercased name\n   from dyncache import cache\n\n\n   # Use with default options. It will create a file \"circle_area.dyncache\" into\n   # the current directory.\n   @Cache()\n   def circle_area(radius):\n       return 3.14159 * (radius ** 2)\n       \n\n   # Empty parentheses are not required for the decorator.\n   @Cache\n   def circle_area(radius):\n       return 3.14159 * (radius ** 2)\n\n\n   circle_area(2)  # Calculates and returns\n   circle_area(3)  # Calculates and returns\n   circle_area(2)  # Returns from cache\n\n\n   # Saves the cache to /tmp/hello.world.\n   @Cache(root=\"/tmp\", filename=\"hello.world\")\n   def circle_area(radius):\n       ...\n\n\n   # Use for function with large input/output -values.\n   @Cache(largeitems=True)\n   def load_all_api_data_for_a_day(day):\n       ...\n\n\n   # When items are small and cache would update too often, setting autowrite to\n   # False lets you control when the cached data is written to the file.\n   cache = Cache(autowrite=False)\n   @cache\n   def really_frequent_function(a, b):\n       ...\n   ...\n   cache.write()  # Write cache data to the file\n   sys.exit(0)\n\n\nContributing\n============\n\n* Send any issues to GitHub's issue tracker.\n* Before sending a pull request, format it with `Black`_ (-Sl79)\n* Any changes must be updated to the documentation\n* All pull requests must be tested with tox (if you are using pyenv, add the installed versions for py35-py38 and pypy3 to .python-version at the root of this repository before running tox)\n\n\n.. _`Black`: https://github.com/psf/black\n\n.. |pypi| image:: https://img.shields.io/pypi/v/dyncache.svg\n    :alt: PyPI\n    :target: https://pypi.org/project/dyncache/\n.. |docs| image:: https://readthedocs.org/projects/dyncache/badge/?version=latest\n    :alt: Read the Docs\n    :target: http://dyncache.readthedocs.io/en/latest/\n.. |license| image:: https://img.shields.io/github/license/b10011/dyncache.svg\n    :alt: License\n    :target: https://github.com/b10011/dyncache/blob/master/LICENSE\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Dynamic input-output caching for deterministic functions",
    "version": "0.1.2",
    "project_urls": {
        "Documentation": "https://dyncache.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/b10011/dyncache",
        "Repository": "https://github.com/b10011/dyncache"
    },
    "split_keywords": [
        "function",
        " cache",
        " dataset",
        " ai",
        " machine learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ad659fbeed5e0e4b58c877e9069c5fec18a03939c3bf39f20657d5e833a9bb57",
                "md5": "96f0723b4e34532aa8fc4cdba9be351c",
                "sha256": "b1fac4eac0457a7b48c8685efcc204a9244e3ae216a0e2438689d421248bc742"
            },
            "downloads": -1,
            "filename": "dyncache-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "96f0723b4e34532aa8fc4cdba9be351c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.5",
            "size": 5865,
            "upload_time": "2025-01-02T10:35:49",
            "upload_time_iso_8601": "2025-01-02T10:35:49.984336Z",
            "url": "https://files.pythonhosted.org/packages/ad/65/9fbeed5e0e4b58c877e9069c5fec18a03939c3bf39f20657d5e833a9bb57/dyncache-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "630647f072d2d098ce7ae4e0fc241d2cafc65e49168d6396e4c26c79c2194ed1",
                "md5": "fd2a1c9a9dc73267d879427fd7745f97",
                "sha256": "6ff39bc33488787001667c91fc7556dc035c7891a219fa2b1623d1a92897c422"
            },
            "downloads": -1,
            "filename": "dyncache-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "fd2a1c9a9dc73267d879427fd7745f97",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.5",
            "size": 4950,
            "upload_time": "2025-01-02T10:35:52",
            "upload_time_iso_8601": "2025-01-02T10:35:52.298517Z",
            "url": "https://files.pythonhosted.org/packages/63/06/47f072d2d098ce7ae4e0fc241d2cafc65e49168d6396e4c26c79c2194ed1/dyncache-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-02 10:35:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "b10011",
    "github_project": "dyncache",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "dyncache"
}
        
Elapsed time: 0.42147s