This release is a pre-release and may not be stable for production use.
cachescope
Find which Python functions repeat slow work.
Install the alpha release from PyPI:
python -m pip install --pre cachescope
Or install from this checkout and run a script:
python -m pip install .
cachescope run app.py [script arguments]
python -m cachescope run --root . scripts/app.py [script arguments]
--root selects the directory whose functions are eligible for analysis. It
defaults to the script's directory and does not change Python's import paths.
Place this option before the script name; options after the script are passed
to the script. Use cachescope --help for the command syntax.
The report sorts functions by observed repeated work:
- CANDIDATE: repeated successful calls were slow enough to investigate, their comparable results were stable, and the checks found no known risk.
- MAYBE: evidence is incomplete or caching needs a human check, such as unknown/mutable results, factory-created functions, captured state, detected effects, or observation limits.
- UNSAFE: comparable calls with the same observed input returned different results, without ambiguous closure context.
- SKIP: too few useful repeats or too little repeated work was observed.
“Repeat work” is the measured time of repeated successful evaluations, not a promise of elapsed time saved. Times exclude work inside the profiling callback and recursive overlap, but interpreter profiling overhead remains. Function times include callees, so rows are not additive. Recursion receives no independent cache savings estimate. Call-heavy programs can slow down substantially.
Size estimates model normalized argument values. Python has already bound
defaults and positional/keyword arguments when these values are observed.
Consequently, f(), f(1), and f(n=1) can look identical here while occupying
different real cache entries. Estimates assume consistent call spelling; verify
the decorated function with cache_info() on a representative workload.
The report does not prescribe an @lru_cache decorator. Observed numeric-type
key collisions block size advice, and typed=True does not distinguish types
inside tuple arguments.
Only the thread that starts the tracer is observed. Generator, coroutine, and
async-generator functions are skipped. Comparisons support exact built-in int,
float, bool, str, bytes, None, list, tuple, and dict values, preserving dictionary
order. Custom objects, including most method self arguments, are unknown.
Mutable return values require review because caching would share them. Failed
and unfinished calls are excluded from cache-hit and repeated-work estimates.
Observation is bounded: values have depth, item, and byte budgets; each function retains at most 4,096 distinct inputs and 100,000 sequence entries. Retention is budgeted at approximately 4 MiB per function and 32 MiB across records, with a function-count limit as well. These are accounting budgets, not a process RSS limit; active snapshots and interpreter overhead also use memory. Reaching a retention limit is reported. Truncated sequences receive no size/hit-rate estimate.
Source checks recognize common risky calls, import aliases, direct helper calls, external-variable reads, and argument mutations. They are a heuristic: dynamic dispatch, imported helper implementations, and changes in external state can escape detection. A CANDIDATE is evidence from one run, not a proof of purity.
For programmatic use, Tracer supports a context manager and restores a prior
Python profile hook when stopped. That prior hook is suspended during tracing.
Nested tracers and incompatible native hooks are rejected; independent
sys.monitoring tools can coexist. Start and stop a tracer in the same thread.
To develop and check distributions:
python -m pip install -e ".[dev]"
python -m pytest
python -m build
python -m twine check dist/*
CI runs the suite on Python 3.9 through 3.14 on Linux and Windows, and checks
the built wheel and source distribution. The Linux Python 3.9 job uses Ubuntu
22.04, which has a supported setup-python binary for that version.
Maintainers: see the release guide for the TestPyPI rehearsal and Trusted Publishing setup.
Metadata
Release files for cachescope 0.1.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cachescope-0.1.0a1.tar.gz | 24.4 kB | With provenance | Details for cachescope-0.1.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cachescope-0.1.0a1-py3-none-any.whl | Python 3 | none | any | Details for cachescope-0.1.0a1-py3-none-any.whl |
Total release size: 41.7 kB
Release files / cachescope-0.1.0a1.tar.gz
| Download URL | cachescope-0.1.0a1.tar.gz |
|---|---|
| Size | 24.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0ba44c05ff74958ae0926ad999f2cb51629f8bfc20c0d7af5e27a97054244d6
|
|
BLAKE2b-256 checksum How to use checksums |
63f8bdd8ed1393426f38c4eef8d26e69357c75365e29cc4f5a7a3c6975c2fd3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / cachescope-0.1.0a1-py3-none-any.whl
| Download URL | cachescope-0.1.0a1-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7615897c160f85fb491fe5294470c4ee624dd9391abee2c78b5872cdcc38a774
|
|
BLAKE2b-256 checksum How to use checksums |
6ca3b2ae5d1ce3082a9c072feb899245621fb4bcb73bfa89b33519b0ee86c87c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for cachescope 0.1.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cachescope-0.1.0a1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.