--- id: diff-match-patch version: "20241021" license: unclear license_treatment: permissive maintenance: dormant --- # diff-match-patch — Repackaging of Google's Diff Match and Patch libraries. License: permissive · Maintenance: dormant · Downloads: 4.8M/mo ## What it is and what it does diff-match-patch is a Python port of Google's Diff Match and Patch library, originally built in 2006 to power Google Docs. It implements three core text-processing operations: diff (comparing two blocks of text and returning a list of differences), match (finding the best fuzzy match for a search string within a block of text), and patch (applying patches to text with best-effort recovery when the underlying text doesn't match exactly). The library uses Myers' diff algorithm at its core, surrounded by pre-diff speedups and post-diff cleanups to improve both performance and output quality. It also implements a Bitap matching algorithm for flexible matching and patching. With no runtime dependencies and support for Python 3.7 or newer, it's straightforward to integrate into projects that need text synchronization, version control operations, or document comparison functionality. Use it for: - Generate unified diff output between two text documents for version control or change tracking systems - Find the best fuzzy match for a search string within a large block of text, weighted for accuracy and location - Apply patches to text with graceful degradation when the exact context doesn't match - Build document collaboration features that need to track and apply text changes - Implement text-based merge or conflict resolution in plain-text workflows ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides diff, match, and patch algorithms for comparing plain text, finding fuzzy matches, and applying patches—originally built for Google Docs and now maintained as a Python port of Google's Diff Match and Patch library. Yes. The package is mature (first release 2011), has no security vulnerabilities, zero dependencies, and permissive licensing. Dormant maintenance is a minor concern, but the repository is active and tracks a maintained fork. Install it if you need robust diff, match, or patch operations for plain text—it's a well-established tool with low friction and proven algorithms. ## Install pip install diff-match-patch uv add diff-match-patch poetry add diff-match-patch ## Installing diff-match-patch Before you install: Low friction: pure Python wheel with no runtime dependencies and support for Python 3.7 or newer. Dormant maintenance status (last release October 2024, 662 days ago) but repository is not archived and tracks a maintained fork as of August 2024. License in practice: Permissive Apache license allows commercial and private use without restriction, making it suitable for most projects without licensing concerns. Quickstart: from diff_match_patch import diff_match_patch dmp = diff_match_patch() patches = dmp.patch_make(text1, text2) diff = dmp.patch_toText(patches) patches = dmp.patch_fromText(diff) new_text, _ = dmp.patch_apply(patches, text) Verify before relying: - Whether the maintained fork referenced (as of August 2024) is actively developed or if this package itself receives updates independently - Performance characteristics and scalability limits for large text comparisons or patch operations ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 4.8M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags text diff algorithm, fuzzy text matching, patch generation and application, unified diff library, text synchronization, plain text comparison, patch file handling, text-diff, version-control, text-synchronization [View on SkillFed](https://skillfed.io/packages/diff-match-patch) · [View on PyPI](https://pypi.org/project/diff-match-patch/)