Python implementation of VS Code's diff algorithm
Project description
vscodiff
Python implementation of VS Code's diff algorithm, referenced from the VS Code source code.
Features
- Myers diff algorithm (
O(ND)difference) - Line-level diff with subword refinement
- Timeout-aware computation (set max time per diff)
- LRU cache for repeated diff requests
- Move detection support
- Type-safe — fully typed with
py.typedmarker
Installation
Recommended — with uv:
uv add vscodiff
Alternative — with pip:
pip install vscodiff
Requires Python ≥ 3.12.
Quick Start
from vscodiff import VSCDiff, DiffOptions
diff = VSCDiff()
# Compute diff between two strings
result = diff.compute_diff("hello\nworld", "hello\nthere\nworld")
for change in result.changes:
print(f" original lines {change.original}: {change.inner_changes}")
API
VSCDiff
Main diff entry point. Configure with VSCDiffOptions:
from vscodiff import VSCDiff, VSCDiffOptions, DiffOptions
options = VSCDiffOptions(
diff_options=DiffOptions(
ignore_trim_whitespace=True,
max_computation_time_ms=1000,
compute_moves=False,
diff_algorithm="advanced",
),
cache_size=100,
)
diff = VSCDiff(options)
result = diff.compute_diff(original_text, modified_text)
Key Types
| Type | Description |
|---|---|
VSCDiff |
Main diff engine |
DocumentDiff |
Result: identical, quit_early, changes, moves |
DetailedLineRangeMapping |
A changed line range with inner char-level diffs |
RangeMapping |
Character-level diff range |
LinesDiff |
Raw line diff output (changes + moves + timeout) |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 vscodiff-0.1.0.tar.gz.
File metadata
- Download URL: vscodiff-0.1.0.tar.gz
- Upload date:
- Size: 57.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fb5d68a81c7b470057946d13445126197ef0c7f3f1dd84670a7d661fa205a5a
|
|
| MD5 |
272fb394dd21816dfa7acbe2c0bb61d8
|
|
| BLAKE2b-256 |
62562bd0964577f95a0eb0e888fd901f48354bbf9c5dffb2bd75979a5bcc2910
|
Provenance
The following attestation bundles were made for vscodiff-0.1.0.tar.gz:
Publisher:
cd.yml on meymchen/vscodiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vscodiff-0.1.0.tar.gz -
Subject digest:
9fb5d68a81c7b470057946d13445126197ef0c7f3f1dd84670a7d661fa205a5a - Sigstore transparency entry: 1403205547
- Sigstore integration time:
-
Permalink:
meymchen/vscodiff@13448c7c04279146a512c4d97cba735b5e09824c -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/meymchen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@13448c7c04279146a512c4d97cba735b5e09824c -
Trigger Event:
release
-
Statement type:
File details
Details for the file vscodiff-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vscodiff-0.1.0-py3-none-any.whl
- Upload date:
- Size: 53.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58b1c0e42e1c9e0c99201e2bfa726e265468958e3dd1cf81fe05bdd1e9edadfd
|
|
| MD5 |
395ea69d7289639bf4005427b7c74692
|
|
| BLAKE2b-256 |
42ea84d105fb60d034506aaf176a13bbf18e779bba63618f598a88f96bf0894d
|
Provenance
The following attestation bundles were made for vscodiff-0.1.0-py3-none-any.whl:
Publisher:
cd.yml on meymchen/vscodiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vscodiff-0.1.0-py3-none-any.whl -
Subject digest:
58b1c0e42e1c9e0c99201e2bfa726e265468958e3dd1cf81fe05bdd1e9edadfd - Sigstore transparency entry: 1403205622
- Sigstore integration time:
-
Permalink:
meymchen/vscodiff@13448c7c04279146a512c4d97cba735b5e09824c -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/meymchen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@13448c7c04279146a512c4d97cba735b5e09824c -
Trigger Event:
release
-
Statement type: