A lightweight Python utility library for working with strings, lists, and tuples.
View on PyPI »
·
Open an Issue »
Table of Contents
sequencekit is a focused utility library built to simplify everyday sequence manipulation in Python.
Python already provides powerful built-ins and standard-library tools. sequencekit focuses on turning common, repetitive sequence logic into a small and consistent API with predictable behavior, explicit validation, and configurable output formats.
It currently supports:
- Frequency analysis
- Duplicate detection and extraction
- Order-preserving deduplication
- Most/least frequent element lookup
- Circular sequence rotation
- Output conversion to
list,tuple, orstr
The project is intentionally small and focused on readability and usability rather than replacing specialized standard-library tools.
frequency()— count occurrences of each elementcontains_duplicates()— detect whether duplicates existuniqueonly()— extract elements appearing exactly onceduplicates()— extract elements appearing more than onceremove_duplicates()— remove duplicates while preserving ordermost_frequent()— find the most frequent elementleast_frequent()— find the least frequent elementrotate()— circular left/right rotation- Consistent output control with
list,tuple, andstr - Deterministic ordering and tie-breaking
- Explicit error handling
- No third-party runtime dependencies
- Python
- pytest for testing
- setuptools for package building
- PyPI for distribution
- Python
3.7+ pip
Check your Python version:
python --versionInstall the latest release from PyPI:
pip install sequencekitOr clone the repository for development:
git clone https://github.com/IHac-er/sequencekit.git
cd sequencekit
pip install -e .from sequencekit import frequency
frequency("banana")
# {'b': 1, 'a': 3, 'n': 2}
frequency([1, 2, 2, 3])
# {1: 1, 2: 2, 3: 1}from sequencekit import contains_duplicates
contains_duplicates("banana")
# True
contains_duplicates("abc")
# Falsefrom sequencekit import uniqueonly
uniqueonly("banana")
# ['b']
uniqueonly("banana", out="tuple")
# ('b',)
uniqueonly("banana", out="str")
# 'b'from sequencekit import duplicates
duplicates("banana")
# ['a', 'n']
duplicates([1, 2, 2, 3, 3])
# [2, 3]from sequencekit import remove_duplicates
remove_duplicates("banana")
# ['b', 'a', 'n']
remove_duplicates("banana", out="str")
# 'ban'from sequencekit import most_frequent, least_frequent
most_frequent("aabb")
# 'a'
least_frequent("aabbcc")
# 'a'When multiple elements have the same frequency, the first occurring element is returned.
from sequencekit import rotate
rotate("abcd", 1)
# ['b', 'c', 'd', 'a']
rotate("abcd", 1, direction="right")
# ['d', 'a', 'b', 'c']
rotate("abcd", 1, direction="right", out="str")
# 'dabc'rotate() accepts str, list, and tuple inputs and supports left/right rotation through the direction argument.
Functions that return sequences support:
list— defaulttuplestr
Example:
uniqueonly("banana", out="tuple")
# ('b',)
remove_duplicates("banana", out="str")
# 'ban'Invalid output types raise ValueError.
When out="str" is used, the result elements must be strings.
sequencekit is primarily focused on readability, abstraction, consistency, and user-friendliness, rather than specialized performance optimization.
The core utilities are designed around linear-time operations under normal Python hashing assumptions. rotate() currently creates a new rotated sequence instead of performing an in-place mutation.
For performance-critical or repeated in-place rotations, Python's standard-library collections.deque.rotate() is a better-suited tool.
Performance-focused implementations may be explored in future versions while keeping the same public API and overall design.
sequencekit/
├── sequencekit/
│ ├── __init__.py
│ ├── core.py
│ └── _internals.py
├── tests/
│ └── test_core.py
├── pyproject.toml
├── README.md
├── LICENSE
└── .gitignore
__init__.py— public API and package versioncore.py— public utility implementations_internals.py— shared private helpers for validation, frequency mapping, and output conversiontest_core.py— automated testspyproject.toml— package metadata and build configuration
Run the test suite with:
pytestThe current v0.2.0 release has a test suite covering normal behavior, output formats, empty inputs, invalid arguments, deterministic tie-breaking, and the rotate() feature.
Contributions, bug reports, and feature suggestions are highly welcomed.
- Fork the repository
- Create a feature branch
git checkout -b feature/AmazingFeature
- Add or update tests
- Ensure the test suite passes
pytest
- Commit your changes
git commit -m "feat: add AmazingFeature" - Push your branch
git push origin feature/AmazingFeature
- Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Tharun R
- GitHub: IHac-er
- Email:
rtharun2012@gmail.com
Project Link: https://github.com/IHac-er/sequencekit
PyPI: https://pypi.org/project/sequencekit/