https://github.com/edmund-huber/mini_patch
Tiny diffs for Python using difflib's SequenceMatcher
https://github.com/edmund-huber/mini_patch
diff python2 python3
Last synced: 2 months ago
JSON representation
Tiny diffs for Python using difflib's SequenceMatcher
- Host: GitHub
- URL: https://github.com/edmund-huber/mini_patch
- Owner: edmund-huber
- License: mit
- Created: 2018-09-07T18:26:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-18T18:32:36.000Z (over 7 years ago)
- Last Synced: 2025-09-28T14:17:36.900Z (6 months ago)
- Topics: diff, python2, python3
- Language: Python
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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
```