Skip to main content

Python implementation of the patiencediff algorithm

Project description

This package contains the implementation of the patiencediff algorithm, as first described by Bram Cohen.

Like Python’s difflib, this module provides both a convenience unified_diff function for the generation of unified diffs of text files as well as a SequenceMatcher that can be used on arbitrary lists.

Patiencediff provides a good balance of performance, nice output for humans, and implementation simplicity.

The code in this package was extracted from the Bazaar code base.

The package comes with two implementations:

  • A Python implementation (_patiencediff_py.py); this implementation only requires a Python interpreter and is the more readable version of the two

  • A C implementation implementation (_patiencediff_c.c); this implementation is faster, but requires a C compiler and is less readable

Usage

To invoke patiencediff from the command-line:

python -m patiencediff file_a file_b

Or from Python:

>>> import patiencediff
>>> print ''.join(patiencediff.unified_diff(
...      ['a\n', 'b\n', 'b\n', 'c\n'],
...      ['a\n', 'c\n', 'b\n']))
---
+++
@@ -1,4 +1,3 @@
 a
+c
 b
-b
-c

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

patiencediff-0.2.5.tar.gz (29.1 kB view details)

Uploaded Source

File details

Details for the file patiencediff-0.2.5.tar.gz.

File metadata

  • Download URL: patiencediff-0.2.5.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for patiencediff-0.2.5.tar.gz
Algorithm Hash digest
SHA256 0e63c8aa547ead9c64aee4ddb0dccc56678e61c87e43ca043eb77442d874b1b4
MD5 e3c1c2ee842c0c81fa89442a20085f5e
BLAKE2b-256 5087c580e80fb58c44577e2b18187891bf2c6b4f5e6fc29c4ee4049b03cf780a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page