Skip to main content

binary diff and patch using the BSDIFF4-format

Project description

The code is mostly derived from cx_bsdiff (written by Anthony Tuininga, http://cx-bsdiff.sourceforge.net/). The cx_bsdiff code in turn was derived from bsdiff, the standalone utility produced for BSD which can be found at http://www.daemonology.net/bsdiff. In addition to the two functions (diff and patch) cx_bsdiff provides, this package includes:

  • an interface to the BSDIFF4-format

  • command line interfaces: bsdiff4 and bspatch4

  • tests

The bsdiff4 package defines the following high level functions:

diff(src_bytes, dst_bytes) -> bytes

Return a BSDIFF4-format patch (from src_bytes to dst_bytes) as bytes.

patch(src_bytes, patch_bytes) -> bytes

Apply the BSDIFF4-format patch_bytes to src_bytes and return the bytes.

file_diff(src_path, dst_path, patch_path)

Write a BSDIFF4-format patch (from the file src_path to the file dst_path) to the file patch_path.

file_patch(src_path, dst_path, patch_path)

Apply the BSDIFF4-format file patch_path to the file src_path and write the result to the file dst_path.

file_patch_inplace(path, patch_path)

Apply the BSDIFF4-format file patch_path to the file path in place.

Example:

>>> import bsdiff4
>>> a = bytes(100000 * 'a')
>>> b = bytearray(a)
>>> b[100:106] = ' diff '
>>> p = bsdiff4.diff(a, bytes(b))
>>> len(p)
154
>>> bsdiff4.patch(a, p) == b
True

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

bsdiff4-1.1.5.tar.gz (8.3 kB view details)

Uploaded Source

File details

Details for the file bsdiff4-1.1.5.tar.gz.

File metadata

  • Download URL: bsdiff4-1.1.5.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bsdiff4-1.1.5.tar.gz
Algorithm Hash digest
SHA256 bbe4758ecde4e9fe7d46c2cf1b6052a8fccb7b6b4dd9eb6ab0133c02e9505526
MD5 5b1a97413ac4c647f71b82077478b97d
BLAKE2b-256 12a7e76afa32f205469e87a0454e731bc9d57f04237da4c0e1d0801a912a1940

See more details on using hashes here.

Supported by

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