fast-diff-match-patch
Packages the C++ implementation of google-diff-match-patch for Python for fast byte and string diffs.
What it is and what it does
fast_diff_match_patch is a Python wrapper around a C++ implementation of Google's diff-match-patch library, designed to compute differences between text or byte strings much faster than the pure-Python port. It exposes a single `diff()` function that takes two strings or bytes and returns a sequence of operations (delete, keep, insert) with their lengths or content, optionally formatted as patches. The package releases the Global Interpreter Lock during diffing, allowing use in multi-threaded applications.
The library supports several tuning options: `timelimit` to cap computation time, `checklines` to optimize line-based text, `cleanup` to choose semantic or efficiency-focused post-processing, and `counts_only` to return operation lengths or full strings. It handles both Unicode strings and byte sequences, though Windows has limitations with characters outside the Basic Multilingual Plane.
Use it for:
- Generate diffs between code versions or document revisions for version control or review systems.
- Detect and highlight changes in text files for diff viewers or collaborative editing tools.
- Produce patch files for applying changes to source code or configuration.
- Compare large documents or byte streams where pure-Python diff is too slow.
- Integrate fast text comparison into multi-threaded applications without GIL contention.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Wraps the C++ implementation of google-diff-match-patch to perform fast string and byte comparisons, returning diff operations or patches.
Yes, if you need fast string or byte diffs. The package is stable, permissively licensed, has no known vulnerabilities, and offers prebuilt wheels for common platforms. Maintenance is dormant but the code is mature; install friction is moderate due to compilation but mitigated by wheel availability. Not worth installing if you only diff small strings or can tolerate slower pure-Python performance.
Install
fast-diff-match-patch on PyPI
pip
pip install fast-diff-match-patchuv
uv add fast-diff-match-patchpoetry
poetry add fast-diff-match-patchInstalling fast-diff-match-patch
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for Python 3.6–3.12 on macOS, Linux, and Windows. Maintenance is dormant (last release 2024-04-23, last commit 2024-06-13), but the repository remains active and unarchived.
License in practice
Licensed under Apache License 2.0 (permissive), allowing free use, modification, and distribution with minimal restrictions.
Quickstart
pip install fast_diff_match_patch
from fast_diff_match_patch import diff
changes = diff("Hello world.", "Goodbye moon.")
for op, length in changes:
print(f"{op}: {length} chars")
Verify before relying
- Whether the package works reliably on Python 3.13+ despite classifier support only through 3.12.
- Performance characteristics on very large documents compared to pure-Python alternatives.
- Whether the GIL release during diff operations provides measurable benefit in typical multi-threaded scenarios.
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 843 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 494,506/month — #6,347 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fast_diff_match_patch-2.1.0-cp310-cp310-macosx_10_9_universal2.whl; fast_diff_match_patch-2.1.0-cp310-cp310-macosx_10_9_x86_64.whl; fast_diff_match_patch-2.1.0-cp310-cp310-macosx_11_0_arm64.whl; fast_diff_match_patch-2.1.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl; fast_diff_match_patch-2.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; fast_diff_match_patch-2.1.0-cp310-cp310-musllinux_1_1_i686.whl; fast_diff_match_patch-2.1.0-cp310-cp310-musllinux_1_1_x86_64.whl; fast_diff_match_patch-2.1.0-cp310-cp310-win32.whl; fast_diff_match_patch-2.1.0-cp310-cp310-win_amd64.whl; fast_diff_match_patch-2.1.0-cp311-cp311-macosx_10_9_universal2.whl; fast_diff_match_patch-2.1.0-cp311-cp311-macosx_10_9_x86_64.whl; fast_diff_match_patch-2.1.0-cp311-cp311-macosx_11_0_arm64.whl; fast_diff_match_patch-2.1.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl; fast_diff_match_patch-2.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; fast_diff_match_patch-2.1.0-cp311-cp311-musllinux_1_1_i686.whl; fast_diff_match_patch-2.1.0-cp311-cp311-musllinux_1_1_x86_64.whl; fast_diff_match_patch-2.1.0-cp311-cp311-win32.whl; fast_diff_match_patch-2.1.0-cp311-cp311-win_amd64.whl; fast_diff_match_patch-2.1.0-cp312-cp312-macosx_10_9_universal2.whl; fast_diff_match_patch-2.1.0-cp312-cp312-macosx_10_9_x86_64.whl
Keywords: diff, compare, Google, match, patch, diff_match_patch, native, fast
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
diff-match-patchProvides diff, match, and patch algorithms for…
permissive · top 5,000 on PyPI
bsdiff4bsdiff4 creates and applies binary patches in…
permissive · top 15,000 on PyPI
dictdifferDictdiffer computes and applies diffs and…
permissive · top 5,000 on PyPI
patchParses and applies unified diff patches to…
permissive · top 15,000 on PyPI
datadiffGenerates human-readable diffs of Python data…
permissive · top 15,000 on PyPI
jsondiffComputes structured diffs between JSON and…
permissive · top 5,000 on PyPI
xmldiffxmldiff compares two XML files or trees and…
permissive · top 15,000 on PyPI
whatthepatchParses and applies patch files in multiple diff…
permissive · top 5,000 on PyPI
patch-ngParses and applies unified diff patches to…
permissive · top 5,000 on PyPI
langdiffLangDiff streams structured LLM outputs to…
permissive · top 15,000 on PyPI