cachey


Namecachey JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttp://github.com/dask/cachey/
SummaryCaching mindful of computation/storage costs
upload_time2020-03-11 15:34:08
maintainerMatthew Rocklin
docs_urlNone
author
requires_python>=3.6
licenseBSD
keywords
VCS
bugtrack_url
requirements heapdict
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Caching for Analytic Computations
---------------------------------

Humans repeat stuff.  Caching helps.

Normal caching policies like LRU aren't well suited for analytic computations
where both the cost of recomputation and the cost of storage routinely vary by
one million or more.  Consider the following computations

```python
# Want this
np.std(x)        # tiny result, costly to recompute

# Don't want this
np.transpose(x)  # huge result, cheap to recompute
```

Cachey tries to hold on to values that have the following characteristics

1. Expensive to recompute (in seconds)
2. Cheap to store (in bytes)
3. Frequently used
4. Recenty used

It accomplishes this by adding the following to each items score on each access

    score += compute_time / num_bytes * (1 + eps) ** tick_time

For some small value of epsilon (which determines the memory halflife.) This
has units of inverse bandwidth, has exponential decay of old results and
roughly linear amplification of repeated results.

Example
-------

```python
>>> from cachey import Cache
>>> c = Cache(1e9, 1)  # 1 GB, cut off anything with cost 1 or less

>>> c.put('x', 'some value', cost=3)
>>> c.put('y', 'other value', cost=2)

>>> c.get('x')
'some value'
```

This also has a `memoize` method

```python
>>> memo_f = c.memoize(f)
```

Status
------

Cachey is new and not robust.



            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/dask/cachey/",
    "name": "cachey",
    "maintainer": "Matthew Rocklin",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "mrocklin@gmail.com",
    "keywords": "",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/c6/9c/e3c959c1601013bf8a72e8bf91ea1ebc6fe8a2305bd2324b039ee0403277/cachey-0.2.1.tar.gz",
    "platform": "",
    "description": "Caching for Analytic Computations\n---------------------------------\n\nHumans repeat stuff.  Caching helps.\n\nNormal caching policies like LRU aren't well suited for analytic computations\nwhere both the cost of recomputation and the cost of storage routinely vary by\none million or more.  Consider the following computations\n\n```python\n# Want this\nnp.std(x)        # tiny result, costly to recompute\n\n# Don't want this\nnp.transpose(x)  # huge result, cheap to recompute\n```\n\nCachey tries to hold on to values that have the following characteristics\n\n1. Expensive to recompute (in seconds)\n2. Cheap to store (in bytes)\n3. Frequently used\n4. Recenty used\n\nIt accomplishes this by adding the following to each items score on each access\n\n    score += compute_time / num_bytes * (1 + eps) ** tick_time\n\nFor some small value of epsilon (which determines the memory halflife.) This\nhas units of inverse bandwidth, has exponential decay of old results and\nroughly linear amplification of repeated results.\n\nExample\n-------\n\n```python\n>>> from cachey import Cache\n>>> c = Cache(1e9, 1)  # 1 GB, cut off anything with cost 1 or less\n\n>>> c.put('x', 'some value', cost=3)\n>>> c.put('y', 'other value', cost=2)\n\n>>> c.get('x')\n'some value'\n```\n\nThis also has a `memoize` method\n\n```python\n>>> memo_f = c.memoize(f)\n```\n\nStatus\n------\n\nCachey is new and not robust.\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Caching mindful of computation/storage costs",
    "version": "0.2.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "da4c687f69d948f07b48eb28137cce5e",
                "sha256": "49cf8528496ce3f99d47f1bd136b7c88237e55347a15d880f47cefc0615a83c3"
            },
            "downloads": -1,
            "filename": "cachey-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "da4c687f69d948f07b48eb28137cce5e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6415,
            "upload_time": "2020-03-11T15:34:07",
            "upload_time_iso_8601": "2020-03-11T15:34:07.347458Z",
            "url": "https://files.pythonhosted.org/packages/57/f0/e24f3e5d5d539abeb783087b87c26cfb99c259f1126700569e000243745a/cachey-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "25f1e2038b319badf1ba0469b8f6d27e",
                "sha256": "0310ba8afe52729fa7626325c8d8356a8421c434bf887ac851e58dcf7cf056a6"
            },
            "downloads": -1,
            "filename": "cachey-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "25f1e2038b319badf1ba0469b8f6d27e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6461,
            "upload_time": "2020-03-11T15:34:08",
            "upload_time_iso_8601": "2020-03-11T15:34:08.721145Z",
            "url": "https://files.pythonhosted.org/packages/c6/9c/e3c959c1601013bf8a72e8bf91ea1ebc6fe8a2305bd2324b039ee0403277/cachey-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-03-11 15:34:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dask",
    "github_project": "cachey",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "heapdict",
            "specs": []
        }
    ],
    "lcname": "cachey"
}
        
Elapsed time: 0.01505s