Skip to main content

Python bindings for imara-diff, providing efficient diffing with identity preservation

Project description

imarapy

中文文档

Python bindings for the imara-diff Rust library, providing efficient diffing for Python objects with identity preservation.

Features

  • Fast Diffing: Leverages the imara-diff Rust crate for high-performance diffing.
  • Multiple Algorithms: Supports histogram (default), myers, and dmp (diff-match-patch).
  • Object Support: Handles arbitrary Python objects by mapping them to unique tokens via __eq__.
  • Identity Preservation: Returns the original object instances from your input lists in the diff results, respecting custom __eq__ implementations without losing object identity.

Installation

Via PyPI

pip install imarapy

Usage

import imarapy

before = ["line1", "line2", "line3"]
after  = ["line1", "changed", "line3"]

# Default algorithm: histogram
deltas = imarapy.diff(before, after)

# Choose algorithm explicitly
deltas = imarapy.diff(before, after, algorithm="histogram")  # imara-diff Histogram
deltas = imarapy.diff(before, after, algorithm="myers")      # imara-diff Myers
deltas = imarapy.diff(before, after, algorithm="dmp")        # diff-match-patch

for d in deltas:
    print(d.type)               # "Insert" | "Delete" | "Change"
    print(d.source.position)    # position in before
    print(d.source.lines)       # affected lines in before
    print(d.target.position)    # position in after
    print(d.target.lines)       # affected lines in after

Constants: imarapy.DELTA_TYPE_INSERT, imarapy.DELTA_TYPE_DELETE, imarapy.DELTA_TYPE_CHANGE

Please refer to demo.py for more usage examples.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

imarapy-0.3.1-cp312-cp312-manylinux_2_28_x86_64.whl (291.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

imarapy-0.3.1-cp312-cp312-manylinux_2_28_aarch64.whl (280.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

imarapy-0.3.1-cp312-cp312-macosx_11_0_arm64.whl (282.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

imarapy-0.3.1-cp312-cp312-macosx_10_12_x86_64.whl (289.4 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

imarapy-0.3.1-cp311-cp311-manylinux_2_28_x86_64.whl (291.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

imarapy-0.3.1-cp311-cp311-manylinux_2_28_aarch64.whl (280.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

imarapy-0.3.1-cp311-cp311-macosx_11_0_arm64.whl (286.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

imarapy-0.3.1-cp311-cp311-macosx_10_12_x86_64.whl (292.0 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

imarapy-0.3.1-cp310-cp310-manylinux_2_28_x86_64.whl (291.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

imarapy-0.3.1-cp310-cp310-manylinux_2_28_aarch64.whl (280.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

imarapy-0.3.1-cp310-cp310-macosx_11_0_arm64.whl (286.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

imarapy-0.3.1-cp310-cp310-macosx_10_12_x86_64.whl (292.2 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file imarapy-0.3.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5abb0ca90291f3d15ddca577bdb460c1b620d15b7ac0eb6ec05f9468e322b6fd
MD5 ee967b61faec9d60f410c4d4078b8fdc
BLAKE2b-256 74a046236e0404d62d92ab6df38a748f7d3678eabbfc62f949ea93a8a10ef647

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 48ebbfa82ddd78d46dcc483d9e18305c68148a043d8054beadc05df00619c900
MD5 8998ff7a8c30748b3e52f8cbc81a06b1
BLAKE2b-256 7f94720ae25028f95df6157a52b51f7bad95180afbce3f245ad0869a6fec0e21

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dd2ca6a8793972caae385a39b18eea48729326776905cbe4a1b881e34a730f03
MD5 46f160754120dccbf942d6cf6238c4ee
BLAKE2b-256 922d484d286e16404eb4308ae42e448cef85c0571a079d035f944b9f10cd308f

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ca24a22ecdb1665ec12329b3a462272f4e97f78c4c978edaa141effd05886c56
MD5 74f2410eb6298a1b1aaa12f7430f8214
BLAKE2b-256 26b953f60147e100b293915a926f36e51bb4986ab2694821287c19267a4b4811

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9522a5aa01d18248780d26c22359abb21ba3c22ec4ba3e7a5677377c1e032525
MD5 3b6508edc7e9485d92231b05f8561965
BLAKE2b-256 19804b0f94e26afe4e2e9a613841da416eabde115facc350a33558c59f0648ad

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4ad6403ee7c0cc2777eaf114d07c0789b2bc74c370a0dfccba220db4be10a64e
MD5 7cf67317f1b4e418de537042324b458f
BLAKE2b-256 a834b9877a36d294d0a1f42b7543ce28bccc607ba79165ad101e62d3bc3a5589

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5902783ef3ce8f2cb39340637e93ff5cbffb612301d23a516dbf4a0adb041699
MD5 d5516a4cf3e8433c891223ba7f882197
BLAKE2b-256 db1d27b754cf7529c07e91388178b1dcd03bb2b5a18ea05f80730392c42704f1

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f94985886499de3fd27e9d78fe13b4b915cb37b5ab69fcef3cd54a62101e0431
MD5 8997f1565fe8e24d0f337db259c07539
BLAKE2b-256 33faa95f9f5e2a44b62f177ff373546ff56f2e0fbb4febcc270e01df7e7853b1

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3901fda8012f16aa3b640bd2fcbe84795e2540b9c308599b78bb781dd804ea93
MD5 7f9736b33013cb9b6d33300a0de20217
BLAKE2b-256 40c29910ea0cd787f370007c08a2a2be73a09106ed091bfcbcf2dd572ae46e1a

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a83357ddbf38336de0b25bff1b7b638c25ceb21b409f0ea74313050c406ad845
MD5 4923103218a6c6fa459acb5e275dc7dd
BLAKE2b-256 20ff8ea2390173131a7c50010d59d347895b17480eabf6080459c7cc21119347

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 873719f7f5cabc4c91b1c7d519a98a75459e038c3dc53f178bab5d25f5f96292
MD5 afddd24b83f16fc29d80c955db859ac9
BLAKE2b-256 348121489af426a594d31c973175621a3b7b88c709e92d1ec847f121bc1321aa

See more details on using hashes here.

File details

Details for the file imarapy-0.3.1-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for imarapy-0.3.1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 450588d3b32fae3767f7ce801a33618af44a3884cc3ee96fc3e482f36f30c172
MD5 76a292437805392a67b7db02d50bbe6e
BLAKE2b-256 13c198a0993b2608977765ed7286e31141ad2392a9d7bf1c27392862758a0e1b

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