{"id":4194,"library":"pylev","title":"pylev","description":"pylev is a pure Python implementation for calculating the Levenshtein distance between two strings, notable for its New BSD license unlike many other GPL-licensed alternatives. The current version is 1.4.0. It has an irregular release cadence, with updates addressing performance improvements and minor fixes.","status":"active","version":"1.4.0","language":"en","source_language":"en","source_url":"https://github.com/toastdriven/pylev","tags":["levenshtein","string","distance","text processing","utility"],"install":[{"cmd":"pip install pylev","lang":"bash","label":"Install pylev"}],"dependencies":[],"imports":[{"symbol":"levenshtein","correct":"import pylev\ndistance = pylev.levenshtein('string1', 'string2')"}],"quickstart":{"code":"import pylev\n\nstr1 = 'kitten'\nstr2 = 'sitting'\ndistance = pylev.levenshtein(str1, str2)\n\nprint(f\"Levenshtein distance between '{str1}' and '{str2}': {distance}\")","lang":"python","description":"Calculates the Levenshtein distance between two simple strings."},"warnings":[{"fix":"Always use `pylev.levenshtein()` for the optimized algorithm. If you explicitly need the naive implementation, use `pylev.classic_levenschtein()`.","message":"In v1.1.0, a much faster Levenshtein variant was introduced and became the default `pylev.levenshtein()`. The older, naive implementation was renamed to `pylev.classic_levenschtein()`. While aliases for backward-compatibility were added in v1.2.0, relying on the older, slower method or its original name is deprecated and should be avoided in new code.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Ensure all calls to pylev functions use the correct spelling 'levenshtein' (without a 'c').","message":"In v1.2.0, all incorrect spellings of 'Levenshtein' in method names were corrected. While older, misspelled method names were aliased for backward-compatibility, new code should exclusively use the correctly spelled versions to prevent potential future breakage or confusion.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"For word-level distance, convert strings to lists of words: `pylev.levenshtein(sentence1.split(), sentence2.split())`.","message":"`pylev.levenshtein()` computes the character-level Levenshtein distance between strings. If you intend to calculate word-level distance between sentences or phrases, you must first pre-process the strings into lists of words (e.g., using `str.split()`). Passing raw sentences will treat each character as an individual item.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}