Skip to main content

Tiny diffs using difflib's SequenceMatcher

Project description

Do you have textual or binary data that you need to patch?

>>> a = 'you say yes, i say no'
>>> b = 'you say stop, and i say go go go'

But you want a smaller patchfile than what difflib's unified_diff() creates?

>>> diff = '\n'.join(difflib.unified_diff(a, b))
>>> len(diff)

mini_patch also uses difflib's SequenceMatcher machinery, but it creates tiny patches:

>>> patch = mini_patch.make_mini_patch(a, b)
>>> print patch
'0!d:8,2;i:11,$3$top;i:12,$4$ and;r:19,1,$1$g;i:21,$6$ go go;'
>>> len(patch)

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

mini_patch-0.0.2.tar.gz (2.4 kB view hashes)

Uploaded source

Built Distributions

mini_patch-0.0.2-py3-none-any.whl (2.7 kB view hashes)

Uploaded py3

mini_patch-0.0.2-py2-none-any.whl (2.7 kB view hashes)

Uploaded py2

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page