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.46-cp314-cp314-manylinux_2_28_x86_64.whl (279.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

ocdiff-0.0.46-cp314-cp314-manylinux_2_28_aarch64.whl (260.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

ocdiff-0.0.46-cp314-cp314-macosx_11_0_arm64.whl (242.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

ocdiff-0.0.46-cp313-cp313-manylinux_2_28_x86_64.whl (279.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

ocdiff-0.0.46-cp313-cp313-manylinux_2_28_aarch64.whl (260.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

ocdiff-0.0.46-cp313-cp313-macosx_11_0_arm64.whl (242.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ocdiff-0.0.46-cp312-cp312-manylinux_2_28_x86_64.whl (279.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

ocdiff-0.0.46-cp312-cp312-manylinux_2_28_aarch64.whl (260.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

ocdiff-0.0.46-cp312-cp312-macosx_11_0_arm64.whl (242.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.46-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9342e9c9df721972a6da58fa9958ce5580f122091ae0e75f382c9d3888121c32
MD5 6182524b3065216666839a048a8aac82
BLAKE2b-256 f96c4272b66ffc68db22532228299d3d53abc684f0840cbb05ff52eb7ab7ab6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.46-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e6a471757897f122132d40c080a6c14843005266f05c7e95de9acab55adff47f
MD5 ae01b2c1a686e99277409ca16bae3c75
BLAKE2b-256 99a0ade6bbc8797149c7d7732dd038fd09dd8633036dee04a030aa104d80d759

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.46-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7cd64ca200979d4432980bee0d9f61db39421f90aabc7fe8af28b2fb5a55c858
MD5 0e128466988bd4bfa7113656251dfc30
BLAKE2b-256 7d454741a012f0c7dd923e0db11c8accbbe13a833ef54e5b1b7367ca85fcd4fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.46-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 96fa74363a848de967f09fcc247fbb6559f6a76e130d20f2ee755112508b3c91
MD5 275db7bace6a53f4d9b6e094c6582b96
BLAKE2b-256 e68abb729824782f403b0aa61776ced03fc5c3ca1abf43eea84a9a3bfce87457

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.46-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8faec3b1cde0563c48e760cf12eee4afca75882994dcb585f4922ef5ded5981a
MD5 e0d5ed73d5b67253ad7e105478dbd9e8
BLAKE2b-256 7549f4d6dad45866292055a7ba85143aa4a9b3c80690f5a0fc555fba6304628d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.46-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 051efe3bde4e1c458d702f0a88eb510cd6348dd258763e573c79cfecec7e1fc1
MD5 73b1bd53b26e802f7552142750097a9f
BLAKE2b-256 b5bff051d760520347494ebb7f6025f932ff5ef72f6214ae3acb26a309db00a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.46-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 15bd4220ffb8c800ca9c8736f5f3c8b0da3a0011e4678b4784222aba0aca50f1
MD5 391d361849d3e9933e7c2ed66aae29f4
BLAKE2b-256 ce2fcb38460f18d316b488e5d2d0c0ed4c4d16ce3219ea49a717d360118e2fba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.46-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c8d956b443d847219172182019d8b69f30701e28c7ff01b17d4c3da916cf5d99
MD5 470bb40220782558ec36cf037e2597e2
BLAKE2b-256 7811a66c38096e533729d3539d67f4463b504b7305053845e78244f445d91e0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.46-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7430619f544159afac7c68af3178137902142cee6285f9e8a200abdd00bcfd2
MD5 6a2ef4d5871a4b7d5351e373b8cf81a8
BLAKE2b-256 7128ac3082bc7535e2f9b7239e82e9eb134cba3356c9e640c17e125e3b8603e8

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.51

9 files

0.0.50

9 files

0.0.49

9 files

0.0.48

9 files

0.0.47

9 files

This release

0.0.46 This release

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