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) 137 `

mini_patch also uses difflib’s SequenceMatcher machinery, but it creates tiny, ASCII-encoded patches:

` >>> patch = mini_patch.make_mini_patch(a.encode('utf-8'), b.encode('utf-8')) >>> patch '0!d:8,2;i:11,$4$dG9w;i:12,$8$IGFuZA==;r:19,1,$4$Zw==;i:21,$8$IGdvIGdv;' >>> len(patch) 70 `

Project details

Download files

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

Files for mini-patch, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size mini_patch-1.0.0-py2-none-any.whl (4.0 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size mini_patch-1.0.0-py3-none-any.whl (3.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size mini_patch-1.0.0.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page