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

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

ocdiff-0.0.51-cp314-cp314-manylinux_2_28_aarch64.whl (261.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

ocdiff-0.0.51-cp314-cp314-macosx_11_0_arm64.whl (243.0 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

ocdiff-0.0.51-cp313-cp313-manylinux_2_28_x86_64.whl (282.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

ocdiff-0.0.51-cp313-cp313-manylinux_2_28_aarch64.whl (262.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

ocdiff-0.0.51-cp313-cp313-macosx_11_0_arm64.whl (243.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ocdiff-0.0.51-cp312-cp312-manylinux_2_28_x86_64.whl (282.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

ocdiff-0.0.51-cp312-cp312-manylinux_2_28_aarch64.whl (262.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

ocdiff-0.0.51-cp312-cp312-macosx_11_0_arm64.whl (243.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.51-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5194f3ba27c457a06c949220f27f0b11c7868a0b3ebbb3ed6a371be1608d495b
MD5 9c55792047d0810232ea431e036f2a4e
BLAKE2b-256 77e9c3be0a212cc5fde4a9dcf915d8825438bf570da1070fb560be430087c2e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.51-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 61bdda2adf832f1c8b50e511aea39210de38e100ab366a7ceed44778e9a9d1d9
MD5 c1f74acd7302f7b67b276367ec5a6dca
BLAKE2b-256 157ea7851730cdb7401b8018c976f00b6ea865db9041c7275a3c043821877566

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.51-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc47714f7ea6e1f1c87aeb52942b00bcc2913375f24c476f506ca3c45d231536
MD5 9d1d178a9d1f3ac5af2b3c5ecf40ba7d
BLAKE2b-256 1a0d7131c7b9e8dac22385dc9fafb75246522b93c629f511660b902e10ada09c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.51-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0d30fec63cf8dbd945352d1bfd967539e589382a4a4a67152c8fb9bd6ef2fe09
MD5 e4c75be4c0bd1bf11a93d139f90932e0
BLAKE2b-256 4a3a17a572668743525aa02a137cb85b9dc70367da2df47ca09df537b46f5590

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.51-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4d80dab20219d3046862ff5f1795561655e56fe2a5555521563fc8cb849ec7c6
MD5 33148948d8b85b504d9a1259e6dacdc7
BLAKE2b-256 8abc36649a6096daa224fc3f8f89db36ca884e5d07b0dc7b969468972811df4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.51-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5af2eca54fcc00d3e3dfe41c84115bd49e37cf2d381cae69e44d94cffdd5be12
MD5 58fccb8a48ae3d47c31f26b91f5fd69c
BLAKE2b-256 32bd15a8be631d1987d27747d31be084a737b2caa677f892e1b066ce04fbd012

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.51-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 90f594a95a27b9e4afbd85135b542e625558a2050d60997ed3a1745b6b010390
MD5 1a6e40d89deee5c5bda1b676bfa942b1
BLAKE2b-256 f67712511636f30e78ff106fdf269c06cb56cd36e2fa1d4853f8e1fb0e088f7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.51-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 50553336d22c584ea2819bd59038e56f85573a92ca681cb6f7f3472e7d799613
MD5 a5aa35aa07e89656a5193f67f716bae4
BLAKE2b-256 7b86baa64fc91546d4e8d5e2f843ac55157b3fb7f83fd255dcb236aa0d7f3253

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ocdiff-0.0.51-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9bc23d004ef6622d982ded133f93f0e3c84053a915c2ed53414bf21376ea0532
MD5 1f7bef595c0472543154e229c04fbbf5
BLAKE2b-256 dd60c9fb44bf0f4a8e77ed7a28c7659c45db2d99efe1feaf8ddccbb86b2c2fad

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.51 This release

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

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