Skip to main content

tandem-repeat

Rust-backed Python package for exact tandem-repeat detection in Unicode text.

from tandem_repeat import find, find_longest, find_primitive

find("abcabcabc")
# [TandemRepeat(start=0, end=9, substring='abc', repeats=3, ...), ...]

find("aaaaa")
# [TandemRepeat(start=0, end=5, substring='a', repeats=5, ...),
#  TandemRepeat(start=0, end=4, substring='aa', repeats=2, ...), ...]

find_primitive("aaaaa")
# [TandemRepeat(start=0, end=5, substring='a', repeats=5, ...)]

find_longest("xxabcabcabc")
# TandemRepeat(start=2, end=11, substring='abc', repeats=3, ...)

API

find(
    text: str,
    *,
    min_length: int = 1,
    min_repeats: int = 2,
    max_results: int | None = None,
) -> list[TandemRepeat]

find_primitive(
    text: str,
    *,
    min_length: int = 1,
    min_repeats: int = 2,
    max_results: int | None = None,
) -> list[TandemRepeat]

find_longest(
    text: str,
    *,
    min_length: int = 1,
    min_repeats: int = 2,
) -> TandemRepeat | None

TandemRepeat is a frozen dataclass:

@dataclass(frozen=True, slots=True)
class TandemRepeat:
    start: int       # Python character offset, inclusive
    end: int         # Python character offset, exclusive
    substring: str   # repeated unit
    repeats: int     # number of consecutive copies
    period: int      # len(substring) in Python characters
    byte_start: int  # UTF-8 byte offset, inclusive
    byte_end: int    # UTF-8 byte offset, exclusive

The detector works on the exact input code points. It does not normalize text, so precomposed and decomposed Unicode sequences are treated as different strings.

Complexity

find returns a compact vocabulary-style representation, not every occurrence position. This follows the distinction in Stoye and Gusfield's tandem repeat work: the occurrence set can be quadratic, while the vocabulary of tandem repeat types is linear-size. For example, "aaaaa" includes tandem types such as "a" repeated five times and "aa" repeated twice, but it does not expand every overlapping occurrence into separate Python objects.

find_primitive exposes the practical smaller-subunit view explicitly. It normalizes each block to its smallest repeated unit, so "aaaaa" is represented as "a" repeated five times.

The Rust scanner avoids the old all-periods-by-all-starts search for larger inputs. It scans short periods directly and discovers longer-period candidates from repeated fixed-width seeds, then verifies candidates exactly before returning them. This gives near-linear scaling on sparse realistic text while preserving exact compact blocks for emitted results. Dense fully periodic text uses a separate linear fast path for find_longest.

find_longest returns one result and avoids result-set explosion. On sparse text the benchmark suite now covers inputs up to 100k characters; on dense text it covers 100k-character fully periodic inputs.

Reference:

  • Jens Stoye and Dan Gusfield, "Linear time algorithms for finding and representing all the tandem repeats in a string", JCSS 2004.

Development

This project uses uv, maturin, Rust, Ruff, mypy, and pre-commit.

uv sync --all-extras --dev
uv run maturin develop
uv run pre-commit run --all-files
cargo test
cargo clippy --all-targets -- -D warnings
cargo fmt --check
uv run pytest -q
uv run python benches/bench_scaling.py
uv run python benches/capture_scaling.py

For contribution rules, test expectations, and the release checklist, see CONTRIBUTING.md.

Release

Releases are tag-driven and published by GitHub Actions with PyPI Trusted Publishing. Configure the PyPI trusted publisher for repository dkajtoch/tandem-repeat, workflow .github/workflows/release.yaml, and the protected GitHub environment pypi.

git tag v0.1.0
git push origin v0.1.0

The workflow runs the full Python and Rust quality gates, builds an sdist plus Linux and macOS wheels, validates artifacts with twine check, and publishes from the protected pypi environment.

Benchmarks

The benchmark scripts cover:

  • scaling with text length,
  • scaling with the number of inserted repeat blocks,
  • dense periodic input such as "a" * n,
  • multilingual Arabic, Hebrew, Hindi, CJK, emoji, and mixed-direction text.

The plotted scaling run writes artifacts to bench-results/scaling.csv, bench-results/summary.md, and bench-results/scaling.svg.

Latest local scaling run:

  • Python: 3.11.7
  • Platform: macOS-26.4.1-arm64-arm-64bit
  • Median of 3 trials where noted
  • find and find_primitive capped at 50,000 returned blocks
scenario operation 1k chars 10k chars 50k chars 100k chars 100k results note
sparse random text with one inserted repeat find 0.0050s 0.0577s 0.3145s 0.6650s 1,520 compact vocabulary output
sparse random text with one inserted repeat find_longest 0.0050s 0.0583s 0.3134s 0.6624s 1 same sparse scan, one result
dense single-character periodic text find_longest 0.00008s 0.00070s 0.00355s 0.00686s 1 whole-text fast path
truncated periodic text: ("aab" * n)[:chars] find_primitive 0.0073s 0.1054s 0.4404s 0.9101s 33,336 output-sensitive primitive blocks
dense single-character periodic text find 0.0012s 0.0881s 2.0210s timeout - many vocabulary blocks; 15s timeout

These timings are machine-local measurements, not portable guarantees. The right bound for result-returning methods is output-sensitive: O(n + output) is the practical target for find_primitive, while find can return many compact vocabulary blocks on low-entropy input. find_longest avoids result-set growth because it returns only one block.

Metadata

Release files for tandem-repeat 0.1.0

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

Source distribution (sdist)

Source distribution for tandem-repeat 0.1.0
File Size Uploaded
tandem_repeat-0.1.0.tar.gz 91.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for tandem-repeat 0.1.0
File
tandem_repeat-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details
tandem_repeat-0.1.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
tandem_repeat-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.13+ x86-64 Details
tandem_repeat-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
tandem_repeat-0.1.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
tandem_repeat-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details
tandem_repeat-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
tandem_repeat-0.1.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
tandem_repeat-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.12+ x86-64 Details
tandem_repeat-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
tandem_repeat-0.1.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
tandem_repeat-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.12+ x86-64 Details

Total release size: 3.2 MB

Release files / tandem_repeat-0.1.0.tar.gz

Download URL tandem_repeat-0.1.0.tar.gz
Size 91.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0c7108b4666b54fa4419950ced006edcadab18d13b2f1dc3a6333855f8656a1d
BLAKE2b-256 checksum
How to use checksums
ee481c1ba39e071a3f706fa236c9db7563143c56320cec4f3daabe364b9a026d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL tandem_repeat-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl
Size 284.2 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5b7781dd315466e218e89ed9f321c7967ab570299854a4b9bbe7df075a346a87
BLAKE2b-256 checksum
How to use checksums
2f22b20650ab54f2302bf5072aabc16c43fbba917d0d03169bba0cdb61adc56f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL tandem_repeat-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Size 241.9 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a95dba9030f116278b4969bb4f613b56c78d91a2c28dc6252e339918151261b0
BLAKE2b-256 checksum
How to use checksums
cbad36899bfccf01b339eb89621d12687adc562e449670ba91f9a2b3031c6d97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl

Download URL tandem_repeat-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl
Size 250.9 kB
Tags CPython 3.13 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
168bb9d1045e0bfe01eb043bf0c2596125d9b737c5d28b399e103193c4aa1741
BLAKE2b-256 checksum
How to use checksums
0e3355e486344b588b1a061ee934a410475b1d566972fb14049846846bde2611
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL tandem_repeat-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 284.2 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
142238b64c3abb68956c93301bfd358d5d9ecb335601f35c6e0ef39b768b4662
BLAKE2b-256 checksum
How to use checksums
3a1d48588a44363f9a88208c98c87a4a2611508cd0ce08258d30bc409046f519
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL tandem_repeat-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Size 241.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1bc88085425a1c85bd9c27665406abeb6d95e9f6c0a9ded821caa173f54f3cdd
BLAKE2b-256 checksum
How to use checksums
897988fafda9c1c708df7989f5251c3e954c1431688b39c0ce4feffeb87809a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl

Download URL tandem_repeat-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl
Size 250.9 kB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
14d531a3aeb873580e8157460a52c45ce12b25f81a1263e8d5f6642c937b3958
BLAKE2b-256 checksum
How to use checksums
fba5b309af920b1b71fc20d8b004c2ec4bfd775215d3db5f7473094f579e3816
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL tandem_repeat-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
Size 284.8 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b6ebc9d754d314b4654dc4fd8363bc15b8b59884fc1b675ec040b5407486e757
BLAKE2b-256 checksum
How to use checksums
b33aec5d40f1cd6b80e5385e0d18cbd3c8ac18f94cb0426f8b4f80321665ca74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL tandem_repeat-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Size 244.0 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1f46b0e7f26bfd6401e48fa4d32cbaa34b87eadaf527d2711295d935e18b03bf
BLAKE2b-256 checksum
How to use checksums
4b26b34aa2d69680026fef5a7da777113cbd943bf968cf6f535254eda5556888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl

Download URL tandem_repeat-0.1.0-cp311-cp311-macosx_10_12_x86_64.whl
Size 252.8 kB
Tags CPython 3.11 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
71c51ff2914c49cdab89e11cb29693c0fdb3ebbe57da471fe783fb20b3378f7b
BLAKE2b-256 checksum
How to use checksums
9aeab943b164bc6d8ab761a9dcf43db214bb6a4cb1cf23b74558eb9c967d62c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL tandem_repeat-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
Size 285.1 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
56607504fef1baf3a38373ef5eb713a7b1f670b5a7d5db42380271c0deb00d0b
BLAKE2b-256 checksum
How to use checksums
edb065b71f19c0b5287fb6479599307a4cf621ed3981a6169822b25a837493da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL tandem_repeat-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Size 244.2 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5d81cfdd56b18a4435cf1e9228bfa91b0391adc567f0b176d337b26b727589c5
BLAKE2b-256 checksum
How to use checksums
1cdde77a434f595599bb542e612ac832a22fc687659ce46bfe73e21f2fe4c324
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release files / tandem_repeat-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl

Download URL tandem_repeat-0.1.0-cp310-cp310-macosx_10_12_x86_64.whl
Size 253.0 kB
Tags CPython 3.10 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
569de466cb1be36bbe0b1df2ee893904f39f5d0dfe0de033565d79c534161103
BLAKE2b-256 checksum
How to use checksums
7bd5f75590c8b2c8ea6713ede18e037d56e8429f01c9ad1f304ea89200ceaccd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

13 release files

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