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, you can eg:

from ocdiff import pytest_plugin

pytest_plugin.wrappers.append((lambda o: isinstance(o, int), lambda o: o + 1))  # add 1 to `int` reprs
pytest_plugin.wrappers.append((lambda o: True, lambda o: o))  # else always use the default `rich` repr



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

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

ocdiff-0.0.45-cp314-cp314-manylinux_2_28_aarch64.whl (259.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

ocdiff-0.0.45-cp314-cp314-macosx_11_0_arm64.whl (242.0 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

ocdiff-0.0.45-cp313-cp313-manylinux_2_28_x86_64.whl (278.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

ocdiff-0.0.45-cp313-cp313-manylinux_2_28_aarch64.whl (259.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

ocdiff-0.0.45-cp313-cp313-macosx_11_0_arm64.whl (242.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ocdiff-0.0.45-cp312-cp312-manylinux_2_28_x86_64.whl (279.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

ocdiff-0.0.45-cp312-cp312-manylinux_2_28_aarch64.whl (259.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

ocdiff-0.0.45-cp312-cp312-macosx_11_0_arm64.whl (242.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.45-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2f576c3766edadca6708e266ce7020475c547b29a8f7ea90ba0161290c5e2632
MD5 0f53b9db4f4027a74adb48520d25441e
BLAKE2b-256 d7f83c1a85e0371c608e3c5f5e7a0e8b77fdd2b27d63b5e02a1b2b610f1df67c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.45-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 389ece55f3fe67d036b6e439f544b97b86061a184a0917fcf36cc2628ceaba54
MD5 42e55fca2789c1364b6962586c5e3969
BLAKE2b-256 78aeaad332593bc749c49d2f2782173da5999f75a46d9dc168f305c6f044ddef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.45-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 933204f45c245890d758c36c783939386ad69f24cdab90c4d157e29a5b11e8a6
MD5 63dd551204eb67ddc7a50093cc50ddaa
BLAKE2b-256 28a5bc96a977d8934a02632515107a4401675e2bdea4bf304682253ff4881858

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.45-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3f4c871d5570e2edd933113dc32431819dcb36de4052fc1139b9b968ac9e7699
MD5 f2955c4800db1ec5293487c4496983ff
BLAKE2b-256 b92577af33ebdcd790d3499f93d262fe667e3dd0e3ba128a9816608ecbd80e79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.45-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a529e75e500add4e06da0660ed9e3a7ecb47f167acbb4ebb55ffe312f0c33ec6
MD5 e481637fd69ce771ab707801e4ff2b30
BLAKE2b-256 25a532a3f00e8178a8a53e32c5ec964ea335e98a83a8f064843ae48ea82e6436

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.45-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6a7ae345f865715a42cd562ad373feb86b80ada0c20aff1e521756f00996f0fe
MD5 6c90a927f247ab2f31e96bdb1dbcf7cc
BLAKE2b-256 15ebddd2add7ccc0d11653df290228b4626654e1a0a7577fb0eb13d23956a2ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.45-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fac902ae0818ef76ab01ba5bf9711de646a28910d85b5a2f077f3dd89dd9fdf4
MD5 005d0af7f507967393e67a347f361197
BLAKE2b-256 dbfe22d360e85d4e7745dc7fb4597d65549067ebcec3e27925b6ce48c91286ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.45-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8e3a7dd63b54c2802d4f0e101100e04bf74f8eedaf7c6ac15bc539ac9c638f0a
MD5 f884f76198027154e63097dadeaead33
BLAKE2b-256 b7b3b009fc4042f7869625a95a6cff782e04789c998fd437c2cb49f84aee846e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.45-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08d6fcb3addc81f89d79e340a15308211ed4b057030331c5f8b68e5c516eafcd
MD5 3afe312574c3c292ca5c213793e0d096
BLAKE2b-256 639136baea5da68e37ab78584fdc064207d4fa2670e72f9fcda2ce887eeacb6c

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

0.0.46

9 files

This release

0.0.45 This release

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