skillfed

pylcs

super fast cpp implementation of longest common subsequence

pylcs v0.1.1 213.6K downloads/30d#9,432 on PyPI23
Permissive license Apache 2.0 DORMANT released

What it is and what it does

pylcs is a C++ extension that solves three classic string-comparison problems: finding the longest common subsequence (LCS), longest common substring, and computing edit distance (Levenshtein distance) between two strings. It uses dynamic programming for speed and supports UTF-8 strings including Chinese characters. The package can compare a single string against multiple targets in batch, and includes visualization functions to colorize matching regions with ANSI escape codes.

The primary use case is rapid string similarity analysis in NLP, data deduplication, or sequence alignment tasks where performance matters. It exposes functions like `lcs_sequence_length()`, `lcs_string_length()`, and `edit_distance()` for length computation, plus `_idx` variants that return alignment indices. The package is dormant (last release October 2023, no commits since then) but carries no known security vulnerabilities.

Use it for:

  • Detect duplicate or near-duplicate text records in data cleaning pipelines by computing edit distance or LCS length.
  • Align DNA or protein sequences in bioinformatics by finding longest common subsequences.
  • Measure string similarity in fuzzy matching, autocomplete, or spell-check systems.
  • Batch-compare a query string against many candidates to find the most similar match.
  • Visualize string alignment differences with colored output for debugging or reporting.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Computes longest common subsequence, longest common substring, and edit distance (Levenshtein distance) between strings using C++ dynamic programming, with support for UTF-8 and batch comparisons.

Yes, if you need fast string-comparison algorithms and can tolerate dormant maintenance. The package has no known vulnerabilities, permissive licensing, and adequate Windows binary support. However, verify platform availability (macOS/Linux) and Python version coverage before adopting in production; the last release was October 2023 and the original repository is no longer maintained.

Install

pylcs on PyPI

pip

pip install pylcs

uv

uv add pylcs

poetry

poetry add pylcs

Installing pylcs

Before you install

Medium install friction due to compiled C++ extension requiring pybind11. Binary wheels available for Windows across multiple Python versions (3.5–3.11), but platform support beyond Windows is unclear from the fact sheet.

License in practice

Apache 2.0 is permissive, allowing commercial and private use with minimal restrictions; no notable licensing constraints for typical adoption.

Quickstart

pip install pylcs

import pylcs

# Longest common subsequence length
A = 'We are shannonai'
B = 'We like shannonai'
result = pylcs.lcs_sequence_length(A, B)
print(result)  # 14

# Edit distance
dist = pylcs.edit_distance('aaa', 'aba')
print(dist)  # 1

Requires a C++ compiler and pybind11 at build time; binary wheels provided for Windows Python 3.5–3.11, but non-Windows users may need to compile from source.

Verify before relying

  • Whether binary wheels or source builds are available for macOS and Linux platforms.
  • Current maintenance status and whether the transfer from the original repository is actively supported.
  • Whether the package works with Python versions beyond 3.11.

Package facts

License Apache 2.0 (permissive)
Python support not specified
Install friction medium — platform-specific wheel
Runtime dependencies 1 — pybind11
Maintenance dormant — 1,025 days since the last release
Last repo commit
First released
Downloads 213,623/month — #9,432 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pylcs-0.1.1-cp310-cp310-win_amd64.whl; pylcs-0.1.1-cp311-cp311-win_amd64.whl; pylcs-0.1.1-cp35-cp35m-win_amd64.whl; pylcs-0.1.1-cp36-cp36m-win_amd64.whl; pylcs-0.1.1-cp37-cp37m-win_amd64.whl; pylcs-0.1.1-cp38-cp38-win_amd64.whl; pylcs-0.1.1-cp39-cp39-win_amd64.whl

Tags

longest common subsequencelongest common substringedit distance levenshteinstring similarity matchingsequence alignmentstring diff algorithmlcs implementation
string-algorithmssequence-alignmentc++-extension

More Text Processing packages