Skip to main content

pysayme

Manage agentic code bloat by finding project code that duplicates functions or constants that the project's own installed dependencies already export, or other functions of the project, and fails a pytest test naming the function to call instead.

Clone detectors such as pylint R0801, jscpd and PMD CPD compare text. pysayme compares normalized AST structure, so renamed copies still match, and it compares a project with its dependencies as well as with itself.

Install

pip install pysayme

Use

As a pytest gate

Add a [tool.pysayme] table to pyproject.toml:

[tool.pysayme]
roots = ["src", "tests"]

[tool.pysayme.allow]
"src/app/util.py:runs -> somelib.masks:runs" = "why this copy is deliberate"
"tools/a.py:f -> tools/b.py:g" = "why these two stay apart"

A full pytest run (no path arguments) then includes one pyproject.toml::pysayme item. The item fails if any of these hold:

  • project code duplicates a public dependency function or constant;
  • a project function duplicates, or is inlined in, another project function;
  • an allowlist entry no longer matches (so the list only shrinks);
  • an allowlist entry has no reason.
Flag Effect
--pysayme run the gate even when paths or tests are selected
--pysayme-behaviour also gate on behavioural matches (see behaviour)
--no-pysayme never run it
-m "not pysayme" deselect it

From the command line

pysayme                                   # check, using pyproject.toml
pysayme --dist numpy scipy -- src tests   # explicit dependencies and roots
pysayme check --all                       # include allowlisted matches
pysayme check --no-self                   # skip duplicates within the project
pysayme check --behaviour                 # also run functions to match by behaviour
pysayme rank --top 3                      # rank shape-independent look-alikes

check exits 1 when there are new duplicates or allowlist problems.

pysayme vectorize                         # fail on loops over ndarrays numpy would replace
pysayme advise --top 20                   # rank loops worth refactoring; never fails
pysayme advise --kind PARALLEL JIT        # only some kinds of advice
pysayme advise --profile out.prof         # rank by time measured with cProfile

vectorize is a gate: findings use the allowlist like duplicates do (check --vectorize, pytest --pysayme-vectorize). advise is a research aid like rank: it prints, most valuable first, the loops where a manual change pays (vectorize, spread independent iterations over cores, JIT a scalar recurrence, or fix an O(n^2) pattern). See docs/vectorize.md.

Configuration

Key Default Meaning
roots ["."] project paths to check; git-tracked and unignored .py files
dists discovered installed distributions to check against
requirements requirements file(s) to take dists from
extra-dists, ignore-dists [] add to / remove from the discovered dists
exclude [] fnmatch globs of project paths to skip
allow {} "path:qualname -> module:qualname" (or -> path:qualname) keys mapped to reasons
copy 0.45 shingle Jaccard for a copy
inlined 0.70 share of a library function found inside a project one
min-shingles, min-inlined 12, 30 smallest function compared, and smallest one inlined
private false also match private library code
ambiguous false also report matches that fit several functions
self true also match project functions against each other
jobs all CPUs worker processes and join threads
child-memory an even share of memory resident bytes a behaviour child may hold before it is ended and its call skipped
cache true cache dependency indexes ($PYSAYME_CACHE, else ~/.cache/pysayme)
behaviour false also run project functions and dependency callables (compiled ones included) on seeded probes, and report project functions that behave like one (--behaviour); executes dependency code, so meant as a release gate
introspect true import dependencies' public modules in a child process to find their public names (--no-introspect)

When dists and requirements are both unset, pysayme uses the installed [project] dependencies and extras, falling back to requirements.txt.

Docs

License

Apache-2.0

Metadata

Release files for pysayme 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysayme 0.4.1
File Size Uploaded Provenance Actions
pysayme-0.4.1.tar.gz 141.8 kB With provenance Details for pysayme-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pysayme 0.4.1
File Interpreter ABI Platform Actions
pysayme-0.4.1-py3-none-any.whl Python 3 none any Details for pysayme-0.4.1-py3-none-any.whl

Total release size: 212.7 kB

Release files / pysayme-0.4.1.tar.gz

Download URL pysayme-0.4.1.tar.gz
Size 141.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d99c3980a6e43bf0165447ce53ea19d428586e2f627507158b6f9399280d8217
BLAKE2b-256 checksum
How to use checksums
22b245e1cbab00da657a44ef3a8136f3b800114d6de8d93a1986c8bc5e0cec07
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 27, 2026.

Transparency log

Release files / pysayme-0.4.1-py3-none-any.whl

Download URL pysayme-0.4.1-py3-none-any.whl
Size 70.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
462c7e8991e471f0f25d6168979c417643f05b83c12109d9b465647959f64462
BLAKE2b-256 checksum
How to use checksums
89a603a05f812f8e1206865d683bb4dd2f741d37451219f81091e1c7443c4d5c
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 27, 2026.

Transparency log

Security for pysayme 0.4.1

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.

Select from 2 files

Attestation for pysayme-0.4.1.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 27, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page