skillfed

fast-diff-match-patch

Packages the C++ implementation of google-diff-match-patch for Python for fast byte and string diffs.

fast-diff-match-patch v2.1.0 494.5K downloads/30d#6,347 on PyPI91
Permissive license Apache License 2.0 DORMANT released

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-patch

uv

uv add fast-diff-match-patch

poetry

poetry add fast-diff-match-patch

Installing 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

Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

fast string diff comparisontext difference detectiondiff match patch pythonbyte string comparisongenerate text patchescompare documents quicklydiff operations
text-comparisonperformance-critical

More Text Processing packages