skillfed

cdifflib

C implementation of parts of difflib

cdifflib v1.2.9 233.2K downloads/30d#9,042 on PyPI41
Permissive license Copyright (c) 2013, Matthew Duggan All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:… (full text in the JSON record) DORMANT released

What it is and what it does

cdifflib is a C-language reimplementation of core parts of Python's standard difflib module, specifically the SequenceMatcher class. It trades the flexibility of generic iterables for raw speed: it only accepts lists as input, but performs sequence matching roughly 4x faster than the pure Python version when processing large data. The API is fully compatible with difflib.SequenceMatcher, so you can drop it in as a replacement—even monkey-patch it into difflib itself to accelerate other libraries that use difflib transparently.

The package has no runtime dependencies and compiles to platform-specific wheels. It is marked Production/Stable and supports Python 3.4 and later, though the project is dormant (last release 578 days ago). The main gotcha is that it requires list inputs; anything else gets converted to a list in the constructor, which can be surprising if you pass generators or other iterables expecting lazy evaluation.

Use it for:

  • Accelerating diff operations in large-scale text processing pipelines where sequence matching is a bottleneck.
  • Speeding up test frameworks or code review tools that compare file contents or code snippets.
  • Replacing difflib globally in an application to transparently accelerate any library that depends on difflib.
  • Comparing large lists of structured data (records, tokens, etc.) where Python's difflib would be too slow.

Worth the install?

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

cdifflib provides a C-accelerated reimplementation of Python's difflib.SequenceMatcher for faster sequence comparison on lists, offering roughly 4x speedup over the pure Python version.

Yes, if you have a performance-critical diffing workload on lists and are willing to accept medium install friction (compiled extension). The package is stable, permissively licensed, has no dependencies, and offers a straightforward 4x speedup. Dormant maintenance is a minor concern but not a blocker—the code is mature and the repo remains reachable. Install only if you've profiled and confirmed difflib is actually your bottleneck.

Install

cdifflib on PyPI

pip

pip install cdifflib

uv

uv add cdifflib

poetry

poetry add cdifflib

Installing cdifflib

Before you install

Medium install friction due to compiled C extension requiring platform-specific wheels. The package is dormant (last release 578 days ago) but repo remains active with recent commits; no runtime dependencies simplifies deployment.

License in practice

BSD 2-Clause license (permissive) permits commercial and private use with minimal restrictions—retain copyright notice and disclaimer in distributions.

Quickstart

from cdifflib import CSequenceMatcher
s = CSequenceMatcher(None, ['a', 'b', 'c'], ['a', 'x', 'c'])
match = s.find_longest_match(0, 3, 0, 3)
print(match)  # Match(a=0, b=0, size=1)

Input sequences must be lists; non-list iterables are converted to lists automatically, which may cause unexpected memory or performance behavior with very large iterables.

Verify before relying

  • Whether prebuilt wheels are available for all modern Python versions and platforms beyond the arm64 macOS wheels listed.
  • Current test coverage and whether the package passes on Python 3.13+ given the dormant maintenance status.
  • Whether the 4x speedup claim holds for typical real-world use cases or only for specific input patterns.

Package facts

License Copyright (c) 2013, Matthew Duggan All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.4)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance dormant — 578 days since the last release
Last repo commit
First released
Downloads 233,173/month — #9,042 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: cdifflib-1.2.9-cp310-cp310-macosx_15_0_arm64.whl; cdifflib-1.2.9-cp311-cp311-macosx_15_0_arm64.whl; cdifflib-1.2.9-cp312-cp312-macosx_15_0_arm64.whl; cdifflib-1.2.9-cp313-cp313-macosx_15_0_arm64.whl; cdifflib-1.2.9-cp39-cp39-macosx_15_0_arm64.whl

Keywords: difflib, c, diff

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonTopic :: Software DevelopmentTopic :: Text Processing :: General

Tags

fast sequence diffingc accelerated difflibsequence matcher performancediff algorithm optimizationlist comparison speed
performance-optimizationc-extension

More Software Development packages