{"id":28554719,"url":"https://github.com/danhje/pymesis","last_synced_at":"2025-07-07T07:32:04.790Z","repository":{"id":56406106,"uuid":"292017516","full_name":"danhje/pymesis","owner":"danhje","description":"Memoization decorator for Python, with optional TTL (measured in time or function calls) for the cached results.","archived":false,"fork":false,"pushed_at":"2025-01-03T11:28:53.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-10T05:07:10.922Z","etag":null,"topics":["caching","expiration","memoization","memoize-decorator","python","ttl","ttl-cache"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danhje.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-01T14:17:30.000Z","updated_at":"2025-01-03T11:29:00.000Z","dependencies_parsed_at":"2022-08-15T18:10:16.890Z","dependency_job_id":null,"html_url":"https://github.com/danhje/pymesis","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/danhje/pymesis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhje%2Fpymesis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhje%2Fpymesis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhje%2Fpymesis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhje%2Fpymesis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danhje","download_url":"https://codeload.github.com/danhje/pymesis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhje%2Fpymesis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264034556,"owners_count":23547233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["caching","expiration","memoization","memoize-decorator","python","ttl","ttl-cache"],"created_at":"2025-06-10T05:06:59.442Z","updated_at":"2025-07-07T07:32:04.785Z","avatar_url":"https://github.com/danhje.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pymesis\nMemoization decorator for Python, with optional TTL (measured in time or function calls) for the cached results.\n\n![Testing and linting](https://github.com/danhje/pymesis/workflows/Test%20And%20Lint/badge.svg)\n[![codecov](https://codecov.io/gh/danhje/pymesis/branch/master/graph/badge.svg)](https://codecov.io/gh/danhje/pymesis)\n![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/danhje/pymesis?include_prereleases)\n![PyPI](https://img.shields.io/pypi/v/pymesis)\n\n\n## Installation\n\nUsing pipenv (recommended):\n\n```shell\npipenv install pymesis\n```\n\nUsing pip:\n\n```shell\npip install pymesis\n```\n\n\n## Usage\n\nBasic usage:\n\n```python\nfrom pymesis import memoize\nfrom time import time, sleep\n\n@memoize\ndef slowFunction(*args, **kwargs):\n    sleep(1)\n    return 'Completed'\n\nstart = time()\nprint(slowFunction('some', 'data')\nprint(f'Time elapsed: {time() - start :.1f} seconds\\n')  # First call is slow\n\nstart = time()\nprint(slowFunction('some', 'data')\nprint(f'Time elapsed: {time() - start :.1f} seconds\\n')  # Second call is fast, as data is cached\n\nstart = time()\nprint(slowFunction('some', 'new', 'data')\nprint(f'Time elapsed: {time() - start :.1f} seconds\\n')  # This call is slow, as attributes have changed\n```\n\nWith TTL:\n\n```python\nfrom pymesis import memoize, TTLUnit\nfrom time import time, sleep\n\n@memoize(ttl=1, ttl_unit=TTLUnit.CALL_COUNT) # Only return cached result once, then go back to calling flowFunction\ndef slowFunction(*args, **kwargs):\n    sleep(1)\n    return 'Completed'\n\nstart = time()\nprint(slowFunction('some', 'data')\nprint(f'Time elapsed: {time() - start :.1f} seconds\\n')  # First call is slow\n\nstart = time()\nprint(slowFunction('some', 'data')\nprint(f'Time elapsed: {time() - start :.1f} seconds\\n')  # Second call is fast\n\nstart = time()\nprint(slowFunction('some', 'data')\nprint(f'Time elapsed: {time() - start :.1f} seconds\\n')  # Third call is slow, as cache has expired (TTL=1).\n```\n\nNote that functions are assumed to be unchanged as long as the name is unchanged. Redefined function (with decorator applied again) will return cached result of similar call to the original function.\n\nThe decorator works with methods as well as functions. Note that the same method on two different instances of the same class are considered different methods, therefore a call to the second will not give the cached result from the first.\n\n\u003c!--\nTODO:\n\nHow it works\n\nBuild status\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanhje%2Fpymesis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanhje%2Fpymesis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanhje%2Fpymesis/lists"}