Skip to main content

ocdiff

Fast and simple side-by-side diff library for Python - wraps similar, inspired by icdiff.

Usage

pip install ocdiff
ocdiff.html_diff(
    a: str,
    b: str,
    context_lines: int | None = None,
    max_total_width: int | None = None,
) -> str
ocdiff.console_diff(
    a: str,
    b: str,
    context_lines: int | None = None,
    max_total_width: int | None = None,
) -> str

Example Output

Screenshot

CLI usage

ocdiff a.txt b.txt

pytest plugin

A pytest plugin is provided, it relies on the presence of rich, usage is:

pytest ... -vv --ocdiff

On the assumption that you are following the convention assert actual == expected, there is also:

pytest ... --copy-left

For snapshot testing on the cheap.

To customize the repr for both of the above, override the global ocdiff.pytest_plugin.PRETTY_REPR_CLS with a subclass of ocdiff.repr_helpers.PrettyRepr:




Install/Develop

uv pip install -e '.[dev]'
maturin develop

Make release

  • Add pypi token and user = __token__ to settings (do this once).
  • Upversion pyproject.toml.
export VERSION=$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])'); git tag -a v$VERSION head -m v$VERSION && git push origin v$VERSION

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.

ocdiff-0.0.49-cp314-cp314-manylinux_2_28_x86_64.whl (279.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

ocdiff-0.0.49-cp314-cp314-manylinux_2_28_aarch64.whl (260.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

ocdiff-0.0.49-cp314-cp314-macosx_11_0_arm64.whl (242.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

ocdiff-0.0.49-cp313-cp313-manylinux_2_28_x86_64.whl (279.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

ocdiff-0.0.49-cp313-cp313-manylinux_2_28_aarch64.whl (260.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

ocdiff-0.0.49-cp313-cp313-macosx_11_0_arm64.whl (242.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ocdiff-0.0.49-cp312-cp312-manylinux_2_28_x86_64.whl (279.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

ocdiff-0.0.49-cp312-cp312-manylinux_2_28_aarch64.whl (260.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

ocdiff-0.0.49-cp312-cp312-macosx_11_0_arm64.whl (242.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file ocdiff-0.0.49-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.49-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b3831fb6f0b7f596ddaf1de455bf607129d162e8524f8ab57ae0866994f470bf
MD5 2a87e2e4cd93e5e34c7283b524e6b402
BLAKE2b-256 8a4477a354428aa1e1fb891132b1cf40ebaa2b7d23b113b7058d9647f36b76d9

See more details on using hashes here.

File details

Details for the file ocdiff-0.0.49-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.49-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b2a18cc62169c307230be4fbf901c84653d6362298cc223bdf5411660a50d1c6
MD5 140fee00c655806ac0b6980dc1964b8e
BLAKE2b-256 0588051d6275673ed8b0d9408af14373838cda63ac728564e9f24843314cb364

See more details on using hashes here.

File details

Details for the file ocdiff-0.0.49-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.49-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 32aaeeb9a28d59ef01a8751d70b2863fe9ed126687c55f58474d71dc149d44bc
MD5 35a1b95955976d46a931a5e2c29a007c
BLAKE2b-256 7cbde6bc0692682c6639fcee9533840279d6fc3df8974772bbadb0cde0e3a64c

See more details on using hashes here.

File details

Details for the file ocdiff-0.0.49-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.49-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5cd09175d499e5c016cd312a7b5b2dd1247475d5edaa537062dc004c48cae8d4
MD5 a037cab76d90d8a64d30d5c89af0d97f
BLAKE2b-256 536b80971f1cdf50e14b827bf3107d7a08120f2239c6ed6d2a4f00e5551d6c30

See more details on using hashes here.

File details

Details for the file ocdiff-0.0.49-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.49-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 490a41209bde61c33aea2a949ad78996cc9cfd04ee78d1bf9063959b2c87eed1
MD5 41c242153656b89bbd97bbd35d789fcb
BLAKE2b-256 82c75126bf3d76d70a688a35f3632af726f8a385090147c6ae2a31b29b3200b5

See more details on using hashes here.

File details

Details for the file ocdiff-0.0.49-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.49-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c8b8ee11b0910c3e7555ab17fb300627fabe5f02f038e0feed85d7d8b6d8ba01
MD5 64421d78110430c885d24d7a54c4ee8a
BLAKE2b-256 0873aae5c388d5afff6f0bc309dd5d09d7d37027f58f022127a41c3b6f22985a

See more details on using hashes here.

File details

Details for the file ocdiff-0.0.49-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.49-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 25527e611ff8344b0e52b07ca89fc5b262f7762a87a6b8688637acc675bfdd3f
MD5 a4d78bdb9de9dd2026f8123938307032
BLAKE2b-256 59a25d89ddc8e17fefa0e68efdb1dc239460fddb0212572ca9ddc715d6b58e7b

See more details on using hashes here.

File details

Details for the file ocdiff-0.0.49-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.49-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 805704bfc78136fb1195724450fba422ef27000a8a6a5728ef0983e3599a9c6b
MD5 e79b34171ae9ff2fbb65dc6540bc10f9
BLAKE2b-256 8c512899d3e74faaa92513c413a9366dd5483c1b2aa2440ac5a2dc5af0310504

See more details on using hashes here.

File details

Details for the file ocdiff-0.0.49-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.49-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3ea8084fc89cb3c4644b7bb122b40959f39dfc6e27cae609aea98fbeb9da715e
MD5 f8c398cb9d4223afdfe0b0ad3b8b91d4
BLAKE2b-256 99bd4afc1ab5b3e7d8d23031f642ff352c521e98588f362ddc955732d44f9e6e

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.51

9 files

0.0.50

9 files

This release

0.0.49 This release

9 files

0.0.48

9 files

0.0.47

9 files

0.0.46

9 files

0.0.45

9 files

0.0.44

12 files

0.0.43

12 files

0.0.42

12 files

0.0.33

15 files

0.0.32

12 files

0.0.31

4 files

0.0.30

7 files

0.0.29

10 files

0.0.28

10 files

0.0.27

8 files

0.0.26

4 files

0.0.23

4 files

0.0.22

4 files

0.0.21

4 files

0.0.20

4 files

0.0.19

4 files

0.0.18

4 files

0.0.17

3 files

0.0.15

2 files

0.0.14

2 files

0.0.13

3 files

0.0.12

3 files

0.0.10

1 file

0.0.7

3 files

0.0.6

3 files

0.0.5

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page