Metadata-Version: 2.4
Name: myers-diff
Version: 0.1.0
Summary: High-performance Myers diff algorithm in C with Python bindings
Author-email: Your Name <your.email@example.com>
License: MIT
Project-URL: Homepage, https://github.com/yourusername/myers-diff
Project-URL: Repository, https://github.com/yourusername/myers-diff
Keywords: diff,myers,edit-distance,lcs,algorithm
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: C
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: General
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# myers-diff

High-performance Myers diff algorithm implementation in C with Python bindings.

## Installation

```bash
pip install myers-diff
```

## Usage

```python
import myers_diff

# Compare two lists
list_a = ["hello", "world", "foo", "bar"]
list_b = ["hello", "there", "foo", "baz"]

# Get full edit operations
ops = myers_diff.diff(list_a, list_b)
for op in ops:
    print(f"{op['type']} [{op['index']}]: {op['line']}")
# DELETE [1]: world
# INSERT [1]: there
# DELETE [3]: bar
# INSERT [3]: baz

# Get just the edit count
count = myers_diff.diff_count(list_a, list_b)
print(f"Edit distance: {count}")  # 4

# Bounded diff - early exit if distance exceeds max_d
ops = myers_diff.diff(list_a, list_b, max_d=2)
if ops is None:
    print("Lists are too different (> 2 edits)")
else:
    print(f"Found {len(ops)} edits")
```

## API

### `diff(a, b, max_d=-1)`
Compute the edit operations to transform list `a` into list `b`.

- `a`: Source list of strings
- `b`: Target list of strings  
- `max_d`: Maximum allowed edit distance. If the actual distance exceeds this, returns `None` for early exit. Use `-1` (default) for no limit.

Returns a list of operations `[{"type": "DELETE"|"INSERT", "index": int, "line": str}, ...]` or `None` if `max_d` is exceeded.

### `diff_count(a, b, max_d=-1)`
Get the number of edit operations without building the full operation list.

Returns the count as an integer, or `None` if `max_d` is exceeded.

### `distance(a, b)`
Compute the edit distance using dynamic programming (no early exit option).

Returns the edit distance as an integer.

## Performance

Optimized C implementation with:
- Pre-computed string hashes for fast comparison
- Common prefix/suffix trimming
- Compact trace storage
- Optional early termination with `max_d` parameter

Benchmarks on ~4500 word lists with ~2200 edits:
- Full diff: ~10ms
- Bounded diff with early exit: <1ms

## License

MIT
