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
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ocdiff-0.0.50-cp314-cp314-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ocdiff-0.0.50-cp314-cp314-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 279.7 kB
- Tags: CPython 3.14, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5af1b3e6882ec676dcae3a2a1bac1f6d67e19e36bd0f8a429ac4f44e66143a8
|
|
| MD5 |
55b18a0687c18ef3a7f281557f7b49e9
|
|
| BLAKE2b-256 |
b2fcd5d14eabef4582277cd9222fab33680760be31b281cedf2504f75b144ab0
|
File details
Details for the file ocdiff-0.0.50-cp314-cp314-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ocdiff-0.0.50-cp314-cp314-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 260.5 kB
- Tags: CPython 3.14, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1e7a97429d7e336664856dcdf5cebee1fc2d69f01f4b1a7b917f10ddce3c0a7
|
|
| MD5 |
722e5c6813f333c98c8ed4bda5f4fbd8
|
|
| BLAKE2b-256 |
b7d52116e2ad603cb5013dd88b3d17f8de8b3d25d37cb1d3bf96d71f9b14e442
|
File details
Details for the file ocdiff-0.0.50-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: ocdiff-0.0.50-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 242.8 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d89a779c91b2342e2aa294dd6c2dcb6104cf439ab9ebce9e0c043cbd5f03940
|
|
| MD5 |
8e1361ebc5657a8c55a2c5d3936a0a45
|
|
| BLAKE2b-256 |
30a12b5aa610114f14142b4e43ddbf33229936cc31d90bb11b463db9e5de6ee1
|
File details
Details for the file ocdiff-0.0.50-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ocdiff-0.0.50-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 279.6 kB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d01a3db3b8cd2b3ca413e176dbe73fd2a1f180910f21e14112a868a86c4da4bd
|
|
| MD5 |
8bdcd9dc658b118a6e3dc610e3e5df61
|
|
| BLAKE2b-256 |
8442693206abcf4677b277272e2632e73d5390e9165f52d54ee8d8d88d20c014
|
File details
Details for the file ocdiff-0.0.50-cp313-cp313-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ocdiff-0.0.50-cp313-cp313-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 260.4 kB
- Tags: CPython 3.13, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2076275f2384a686ba0b321b6e02ca1b20fc65d7ae0ae2d8f9e87badb9e0e23c
|
|
| MD5 |
ecda5c091e907e168a7a23a644bb7a14
|
|
| BLAKE2b-256 |
013e03f5abc310eb6e6d82af2f96972e98af2f564cadb0df67dde789c009becf
|
File details
Details for the file ocdiff-0.0.50-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: ocdiff-0.0.50-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 243.0 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b36d1cf377f5ed4ed10d56743e0867fa09e07ee735611012dcb249c2bad0a1c
|
|
| MD5 |
f79acba706122054c7960a7230f48d43
|
|
| BLAKE2b-256 |
068ac62da0ae01b7fec0b6df9e319d39b5e9b7bd52fc62f30783aa3914a6d77a
|
File details
Details for the file ocdiff-0.0.50-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ocdiff-0.0.50-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 279.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7400749b242199b66dbe8ed68cf67dcf2bd164a103986ff7d170b353f7166691
|
|
| MD5 |
8dc475aecfc774089474219a05e7f3a5
|
|
| BLAKE2b-256 |
f75f7950de06a9e3bf6224505228a03bedea89c5ade43242897d65bed6b1888a
|
File details
Details for the file ocdiff-0.0.50-cp312-cp312-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ocdiff-0.0.50-cp312-cp312-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 260.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c15abec3caa342ab21e471f4ef00e0433b22d854a798b600e3f7a60f7ccb202
|
|
| MD5 |
e9a4b61fec5712194f4f6998bcd4aaf9
|
|
| BLAKE2b-256 |
75e917ce61a07cbeb901544d0fa8d7569468b50cd2ef362d4ac2b96d841cb07d
|
File details
Details for the file ocdiff-0.0.50-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: ocdiff-0.0.50-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 242.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b771fc0cd19f5bbed429424b0c6fab60ef427b8a2c9ee0b8af534606a264c13
|
|
| MD5 |
e8616cd496e3f4c2114a81deeba77023
|
|
| BLAKE2b-256 |
21b38460567c71f7c4161a63e724dc3d89c7ca1265de592d53e06280d955d20a
|