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

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

ocdiff-0.0.48-cp314-cp314-manylinux_2_28_aarch64.whl (260.2 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

ocdiff-0.0.48-cp314-cp314-macosx_11_0_arm64.whl (242.5 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

ocdiff-0.0.48-cp313-cp313-manylinux_2_28_x86_64.whl (279.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

ocdiff-0.0.48-cp313-cp313-manylinux_2_28_aarch64.whl (260.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

ocdiff-0.0.48-cp313-cp313-macosx_11_0_arm64.whl (242.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ocdiff-0.0.48-cp312-cp312-manylinux_2_28_x86_64.whl (279.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

ocdiff-0.0.48-cp312-cp312-manylinux_2_28_aarch64.whl (260.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

ocdiff-0.0.48-cp312-cp312-macosx_11_0_arm64.whl (242.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.48-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2ac28a5f332983400ed181717cb2a4c2152433c3e1f1ad4b2ef2937be04bf7b3
MD5 e8474e62e65766b3fba09b3214545926
BLAKE2b-256 7e1508aafeb8ffa81e0d2041c26f0ff24e088c30c24e1127542dbbd5ca3dc82e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.48-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7455cc22b83512cbd365d46f361afef0b372e6bfba0c593167b3852e610780fe
MD5 c5c83a019e8c4dfc811832fa0104ebe5
BLAKE2b-256 6a7bd72c1c05f2460e26d5c938b59dcf1e6596d9548587ebb68b9518e278cc1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.48-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 791f0e90f058ff295b0cda8ccb1491ed7617f9410b9e1f881beb8f0bb5e44e02
MD5 535e39d24084409dc2f9987df7c3f4c5
BLAKE2b-256 5f864ecd3ffc9a8804972aeeb1c24dffc127f21631c045a23b261547fe9341ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.48-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 708eed19ebadaa2157eda6f4ffc75adaa4718179f8ecd9a0f8b17572fdc2db05
MD5 1bcfcd7c4dbf80a70a31f3a099965ae7
BLAKE2b-256 333d7fd07ec735ae6aead8eccbdf7b1426e402ab45e39571d190028b2993b179

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.48-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 baea13aeababa1d6fbeef28d5efba03752a0f6e07afb3a8588fe99438a4a3dd6
MD5 f0d6b82a20586f7908ac831196fc4d3c
BLAKE2b-256 945342550797f1f6d3c56ae8da3dbf1e8416b7d62357eca18a55c13b48e798a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.48-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76947168c52c25e25f4d58900ad6e92b87ff468e80dc8fb5fe11daddf94a196c
MD5 7c5bf373ca59d29115764fb389504acc
BLAKE2b-256 03e2558a6c920d597979d07f9f02f4521cd681d871246fd6b314effa600e30d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.48-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 09ba0e1d7fc3f5b3b8428fbf0a03b2d48af496975002fa41fa58aa48eadc45c4
MD5 d7cd9fc328c6138a440b0e2cf1f80ba6
BLAKE2b-256 61fae4a033ff8d38049a99b3810d202c8a2af3f4ba920c9203e616bc9db61be2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.48-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e1cabb383b6f2687e277558094583f23e3197ced983066e085da08c1f92639eb
MD5 a9386dbac44098b86f49e06a9beb755b
BLAKE2b-256 43dd54a3e05dd23923164a4cd75d6cf561f103d3e7ebb583a46850f71c03037a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.48-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77f3d62ca68cab108c729e5ca474b3473edc972780afe60e21d87bb3303caba0
MD5 57e6ed9ccca009a8aeed0d770e1d3e12
BLAKE2b-256 ab1fcb3205f3b7156ecbd4fda141dcd28bedba9cc595c48324836193758e4b3e

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

This release

0.0.48 This release

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