fastdiff

0.3.0 · active · verified Sat Apr 11

fastdiff is a Python library (current version 0.3.0) that offers a fast, native implementation of a diff algorithm, including a pure Python fallback. It re-implements the core functionality of Python's built-in `difflib` by leveraging Rust compiled to WebAssembly, which can lead to significant performance improvements for string comparisons. The project has an infrequent release cadence, with its last update in May 2021.

Warnings

Install

Imports

Quickstart

This example demonstrates how to import the `compare` function and use it to find the differences between two multi-line strings. The `compare` function returns an iterator of diff operations similar to `difflib`.

from fastdiff import compare

str1 = 'hello\nworld\npython\n'
str2 = 'hello\nwasm\npython\n'

diff_result = compare(str1, str2)
print(list(diff_result))

view raw JSON →