uniqseq
Stream-based deduplication for repeating sequences
What It Does
uniqseq identifies and removes repeated multi-record patterns from streaming data. Unlike traditional line-by-line deduplication tools, it detects when sequences of records repeat, where a record can be a line, a byte sequence, or any delimiter-separated unit.
Works with text streams (line-delimited, null-delimited, etc.) and binary streams (byte-delimited with any delimiter), processes data in a single pass, and maintains bounded memory usage.
Quick Example
# Input with repeated 3-line sequence
$ cat app.log
Starting process...
Loading config
Connecting to DB
Starting process...
Loading config
Connecting to DB
Done
# Remove duplicates (specify window size to match pattern length)
$ uniqseq --window-size 3 app.log
Starting process...
Loading config
Connecting to DB
Done
Key Features
- Sequence detection - Identifies repeating multi-record patterns
- Flexible delimiters - Text with any delimiter or byte streams
- Streaming architecture - Single-pass processing with real-time output
- Memory efficient - Bounded memory usage for unlimited input
- Pattern filtering - Selectively deduplicate with regex patterns
- Content transformation - Match on normalized content while preserving original output
- Python API & CLI - Use as a command-line tool or import as a library
- Sequence libraries - Save and reuse pattern libraries across sessions
Installation
Via Homebrew (macOS/Linux)
brew tap jeffreyurban/uniqseq && brew install uniqseq
Homebrew manages the Python dependency and provides easy updates via brew upgrade.
Via pipx (Cross-platform)
pipx install uniqseq
pipx installs in an isolated environment with global CLI access. Works on macOS, Linux, and Windows. Update with pipx upgrade uniqseq.
Via pip
pip install uniqseq
Use pip if you want to use uniqseq as a library in your Python projects.
From Source
# Development installation
git clone https://github.com/JeffreyUrban/uniqseq
cd uniqseq
pip install -e ".[dev]"
Requirements: Python 3.9+
Quick Start
Command Line
# Basic usage (deduplicate 10-line sequences by default)
uniqseq app.log > clean.log
# Adjust window size for your data
uniqseq --window-size 3 build.log # 3-line patterns
uniqseq --window-size 5 errors.log # 5-line patterns
# Stream processing
tail -f app.log | uniqseq --window-size 5
# Ignore timestamps when comparing
uniqseq --skip-chars 24 timestamped.log
# Only deduplicate ERROR lines
uniqseq --track "^ERROR" app.log
# See what was removed
uniqseq --annotate app.log
Python API
from uniqseq import UniqSeq
# Initialize with configuration
deduplicator = UniqSeq(
window_size=3,
skip_chars=0,
max_history=100000
)
# Process stream
with open("app.log") as infile, open("clean.log", "w") as outfile:
for line in infile:
deduplicator.process_line(line.rstrip("\n"), outfile)
deduplicator.flush(outfile)
Use Cases
- Log processing - Clean repeated error traces, stack traces, debug output
- Build systems - Deduplicate compiler warnings, test failures
- Terminal sessions - Clean up verbose CLI output (from
scriptcommand) - Monitoring & alerting - Reduce noise from repeated alert patterns
- Data pipelines - Filter redundant multi-line records in ETL workflows
- Binary analysis - Deduplicate repeated byte sequences in memory dumps, network captures
How It Works
uniqseq uses a sliding window with hash-based pattern detection:
- Buffering - Maintains a sliding window of N records
- Hashing - Computes a hash for each window position
- History tracking - Records which window patterns have been seen
- Sequence tracking - Tracks known multi-window sequences
- Matching - Compares current windows against history and known sequences
- Transformation - Optionally normalizes content for matching while preserving original data in output
Output is produced with minimal delay. When a window doesn't match any known pattern, the oldest buffered record is immediately emitted.
Documentation
Read the full documentation at uniqseq.readthedocs.io
Key sections:
- Getting Started - Installation and quick start guide
- Use Cases - Real-world examples across different domains
- Guides - Window size selection, performance tips, common patterns
- Reference - Complete CLI and Python API documentation
Development
# Clone repository
git clone https://github.com/JeffreyUrban/uniqseq.git
cd uniqseq
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=uniqseq --cov-report=html
Performance
- Time complexity: O(n) - linear with input size
- Space complexity: O(h + u×w) where h=history depth, u=known sequences, w=window size
- Throughput: Approximately constant records per second
- Memory: Bounded by configurable history depth
License
MIT License - See LICENSE file for details
Author
Metadata
Release files for uniqseq 0.3.0
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 |
|---|---|---|---|---|
| uniqseq-0.3.0.tar.gz | 1.1 MB | With provenance | Details for uniqseq-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uniqseq-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for uniqseq-0.3.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / uniqseq-0.3.0.tar.gz
| Download URL | uniqseq-0.3.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad2d0f82882029c2695bfbce700d90739207f2c148685fe20fafb54e07c7cb9c
|
|
BLAKE2b-256 checksum How to use checksums |
53d332a39283f34d3b113299c8728ea8b0cccbfba880ddba2912bdca73c06c41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 7, 2025.
Transparency logRelease files / uniqseq-0.3.0-py3-none-any.whl
| Download URL | uniqseq-0.3.0-py3-none-any.whl |
|---|---|
| Size | 43.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f25241e2410d368ac8468932b324be3e65dfb483e90f748477055d1cf7706af6
|
|
BLAKE2b-256 checksum How to use checksums |
5c517ef0b398e2c38fced789fce47038d4e012580b22467c4a3532528791c921
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 7, 2025.
Transparency logSecurity for uniqseq 0.3.0
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 uniqseq-0.3.0.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 Dec 7, 2025.
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.