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.47-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.47-cp314-cp314-manylinux_2_28_aarch64.whl (260.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

ocdiff-0.0.47-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.47-cp313-cp313-manylinux_2_28_aarch64.whl (260.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

ocdiff-0.0.47-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.47-cp312-cp312-manylinux_2_28_aarch64.whl (260.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

ocdiff-0.0.47-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.47-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ocdiff-0.0.47-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e19634a3a4ae4093c11fc2ddec6ea31b44b0208614d995be37437e891fa33d6
MD5 0166eabd33a7f03afc3cb60621a1a00e
BLAKE2b-256 8cc16e28bce475d67814501b2674c349a48085a7a3890aa0e1e605aa01bfb2d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.47-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5f8a6b12b5a15bf717ac55b2e76bc09efb9e4ade9cb5b81f89962b4ffe186491
MD5 9f4b891ac10ecf31b557ac12b7408fe9
BLAKE2b-256 4a17a968bff17d104371538099b91edd891eac25b272599f527e2916e6355c42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.47-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2d642d7860d4446b749cb8c3e0d42a324c25ab4aec7e21ad53ba78f6fcb25214
MD5 2cda24335439caf8b9f5e5201d887c82
BLAKE2b-256 05ed44e74bd14e8726652e7132d94cf5e6b7540aacba7d79cc9e2b2b7ef5131a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.47-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7d41100551aa2185b13122052a6b5f3cf22fffc0be4efe22dccd6efebd1f1195
MD5 0ff41a22ba2c5141c4f33ba7bb8d4c4a
BLAKE2b-256 18310057c3c034ec71a5f4b574cebe8b5252688b34f26adf2eb0691c79d0203c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.47-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cc211c1b60b1b2619310b8af06fe8acbe40b8bb2d55277b2b851a57360cc74ad
MD5 d72a313df109d3d790d72d7d49860d70
BLAKE2b-256 69da6af12b41614392c0cf2153ce14e72fb3eabaadeb214382bc6ca45b7c0854

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.47-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07ae1efcec91ad1fa5b153a6d84904bfcb8fd1cc096481e12a75f629f69f8f31
MD5 beb6457359d8d6586c4a23da418044be
BLAKE2b-256 9982d45c92833e649afc97b7390864b3f2e3761a5c182b3aaead957fc7a10147

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.47-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 610a670523a3dd2adf871826b3f5208381a15796d132cb6371febe12961ec024
MD5 51453df17bc7f47bac6510c607bf1021
BLAKE2b-256 56a9665c51c086a0449fee7c2cc6fa6bd9db4bec030047c237673f5c909fe14c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.47-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 88b43d95ec5206c87681dfd11898220c1f70e383db9f226911ab89abb1e86b5d
MD5 dab3477109e25db7046cec1539d81823
BLAKE2b-256 a4abefd69090b4a86902d5d27aa599dfc3259935b154e40017100579293110ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.47-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f1c0196e5a29e02722ad23ad2f853458564a3371431b06fb1d380f4aa852c19f
MD5 73fb2bd6a020e8badf09438515480364
BLAKE2b-256 4892d5ce21cc8ebc458ed9204dbc95200b7c886968c1cbb4965ef526c2423150

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

This release

0.0.47 This release

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