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

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

ocdiff-0.0.50-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.50-cp313-cp313-manylinux_2_28_aarch64.whl (260.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

ocdiff-0.0.50-cp313-cp313-macosx_11_0_arm64.whl (243.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ocdiff-0.0.50-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.50-cp312-cp312-manylinux_2_28_aarch64.whl (260.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

ocdiff-0.0.50-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.50-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.50-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e5af1b3e6882ec676dcae3a2a1bac1f6d67e19e36bd0f8a429ac4f44e66143a8
MD5 55b18a0687c18ef3a7f281557f7b49e9
BLAKE2b-256 b2fcd5d14eabef4582277cd9222fab33680760be31b281cedf2504f75b144ab0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.50-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a1e7a97429d7e336664856dcdf5cebee1fc2d69f01f4b1a7b917f10ddce3c0a7
MD5 722e5c6813f333c98c8ed4bda5f4fbd8
BLAKE2b-256 b7d52116e2ad603cb5013dd88b3d17f8de8b3d25d37cb1d3bf96d71f9b14e442

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.50-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d89a779c91b2342e2aa294dd6c2dcb6104cf439ab9ebce9e0c043cbd5f03940
MD5 8e1361ebc5657a8c55a2c5d3936a0a45
BLAKE2b-256 30a12b5aa610114f14142b4e43ddbf33229936cc31d90bb11b463db9e5de6ee1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.50-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d01a3db3b8cd2b3ca413e176dbe73fd2a1f180910f21e14112a868a86c4da4bd
MD5 8bdcd9dc658b118a6e3dc610e3e5df61
BLAKE2b-256 8442693206abcf4677b277272e2632e73d5390e9165f52d54ee8d8d88d20c014

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.50-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2076275f2384a686ba0b321b6e02ca1b20fc65d7ae0ae2d8f9e87badb9e0e23c
MD5 ecda5c091e907e168a7a23a644bb7a14
BLAKE2b-256 013e03f5abc310eb6e6d82af2f96972e98af2f564cadb0df67dde789c009becf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.50-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b36d1cf377f5ed4ed10d56743e0867fa09e07ee735611012dcb249c2bad0a1c
MD5 f79acba706122054c7960a7230f48d43
BLAKE2b-256 068ac62da0ae01b7fec0b6df9e319d39b5e9b7bd52fc62f30783aa3914a6d77a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.50-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7400749b242199b66dbe8ed68cf67dcf2bd164a103986ff7d170b353f7166691
MD5 8dc475aecfc774089474219a05e7f3a5
BLAKE2b-256 f75f7950de06a9e3bf6224505228a03bedea89c5ade43242897d65bed6b1888a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.50-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1c15abec3caa342ab21e471f4ef00e0433b22d854a798b600e3f7a60f7ccb202
MD5 e9a4b61fec5712194f4f6998bcd4aaf9
BLAKE2b-256 75e917ce61a07cbeb901544d0fa8d7569468b50cd2ef362d4ac2b96d841cb07d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.50-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b771fc0cd19f5bbed429424b0c6fab60ef427b8a2c9ee0b8af534606a264c13
MD5 e8616cd496e3f4c2114a81deeba77023
BLAKE2b-256 21b38460567c71f7c4161a63e724dc3d89c7ca1265de592d53e06280d955d20a

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.51

9 files

This release

0.0.50 This release

9 files

0.0.49

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