{"id":23483,"library":"cydifflib","title":"CyDifflib","description":"A fast Cython-powered implementation of Python's difflib algorithms (SequenceMatcher, unified_diff, etc.). Current version: 1.2.0. Released irregularly, maintained by the RapidFuzz project. Requires Python >=3.9.","status":"active","version":"1.2.0","language":"python","source_language":"en","source_url":"https://github.com/rapidfuzz/CyDifflib","tags":["difflib","cython","sequence-matching","diff","rapidfuzz"],"install":[{"cmd":"pip install cydifflib","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Shared C-extensions, cydifflib may fail to build if rapidfuzz is not present","package":"rapidfuzz","optional":true}],"imports":[{"note":"The stdlib difflib.SequenceMatcher is different; cydifflib.SequenceMatcher is specialized and faster.","wrong":"from difflib import SequenceMatcher","symbol":"SequenceMatcher","correct":"from cydifflib import SequenceMatcher"},{"note":"Similarly, cydifflib.unified_diff returns a generator of strings, while stdlib returns a generator of strings (same API but faster).","wrong":"from difflib import unified_diff","symbol":"unified_diff","correct":"from cydifflib import unified_diff"}],"quickstart":{"code":"from cydifflib import SequenceMatcher\na = \"hello world\"\nb = \"hello earth\"\nsm = SequenceMatcher(None, a, b)\nratio = sm.ratio()\nprint(f\"Similarity: {ratio:.2f}\")","lang":"python","description":"Compute similarity between two strings using SequenceMatcher."},"warnings":[{"fix":"Check the README for supported features. If you need full compatibility, use difflib instead.","message":"CyDifflib's SequenceMatcher is NOT a drop-in replacement for difflib.SequenceMatcher. It has fewer methods (e.g., no get_grouped_opcodes, real_quick_ratio) and behavior may differ slightly.","severity":"gotcha","affected_versions":"all"},{"fix":"Install pre-built wheels from PyPI. If building from source, ensure Cython and a C compiler are installed. Consider using rapidfuzz as a fallback.","message":"The library may fail to compile from source if you have an incompatible Cython version or missing build tools. Pre-built wheels are available for most platforms, but not all.","severity":"gotcha","affected_versions":"all"},{"fix":"Avoid using autojunk parameter or expect it to be ignored. Future versions may raise an error.","message":"The cydifflib.SequenceMatcher object does not support autojunk parameter (ignored). This behavior is deprecated and will be removed in a future version.","severity":"deprecated","affected_versions":"<=1.2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install --upgrade cydifflib' to get the latest version.","cause":"The module is not installed or you're using a very old version that had a different API (pre-1.0).","error":"ImportError: cannot import name 'SequenceMatcher' from 'cydifflib'"},{"fix":"Use difflib.SequenceMatcher if you need get_grouped_opcodes or other missing methods.","cause":"CyDifflib's SequenceMatcher does not implement all methods from stdlib difflib.","error":"AttributeError: 'SequenceMatcher' object has no attribute 'get_grouped_opcodes'"},{"fix":"Decode bytes to str before passing: e.g., a = my_bytes.decode('utf-8')","cause":"CyDifflib expects string inputs, not bytes. It does not handle bytes automatically.","error":"TypeError: Expected str, got bytes"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}