Registry / database / py-memoize

py-memoize

JSON →
library3.1.1pypypi✓ verified 82d ago

A caching library for asynchronous Python applications (asyncio-based) that handles dogpiling properly and provides a configurable & extensible API. Current version 3.1.1. Release cadence is irregular.

pip install py-memoize
INSTALL
IMPORT
SIG · PY-MEMOIZE
P
py-memoize
databasepythonv3.1.1
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Memoizer
import memoize
from memoize import Memoizer

Basic usage: create a Memoizer with an in-memory cache and decorate an async function with ttl in seconds.

import asyncio from memoize import Memoizer from memoize.cache import InMemoryCache, ExpiringCache memoizer = Memoizer(cache=InMemoryCache()) @memoizer.cache(ttl=5) async def fetch_data(key: str) -> str: await asyncio.sleep(1) return f"data-{key}" async def main(): result = await fetch_data("my_key") print(result) asyncio.run(main())
Debug
Known issues
breakingVersion 3.0.0 removed support for Tornado. If you rely on Tornado integration, stay on v2.x.
fix
Use asyncio-based applications or pin version to <3.0.0.
affects: >=3.0.0
breakingVersion 2.0.0 changed exception handling: exceptions are now chained (via __cause__) instead of being added to args. Timeout errors are now also chained.
fix
Update any exception handling logic that relied on checking exception.args for chained exceptions.
affects: >=2.0.0
gotchaThe default cache is InMemoryCache which has no expiration by default. Use ExpiringCache if you need TTL-based expiry.
fix
Explicitly instantiate Memoizer with an ExpiringCache instance and configure ttl in the decorator.
affects: all
gotchaThe decorator requires the wrapped function to be async. Applying it to a sync function will cause a runtime error.
fix
Ensure the decorated function is defined with async def.
affects: all
deprecatedTornado support was deprecated in v1.2.0 and removed in v3.0.0. Tornado-specific imports will raise ImportError.
fix
Migrate to asyncio-based usage.
affects: >=3.0.0
Upgrade
Version history
3.1.1latest on PyPI · released Oct 7, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
Resources
py-memoize — pip install py-memoize · libregistry