mirror of
https://github.com/python/cpython.git
synced 2026-05-13 22:11:05 +00:00
- Make case-swaps half the cost of any other edit - Refactor Levenshtein code to not use memory allocator, and to bail early on no match. - Add comments to Levenshtein distance code - Add test cases for Levenshtein distance behind a debug macro - Set threshold to `(name_size + item_size + 3) * MOVE_COST / 6`. - Reasoning: similar to `difflib.SequenceMatcher.ratio()` >= 2/3: ``` "Multiset Jaccard similarity" >= 2/3 matching letters / total letters >= 2/3 (name_size - distance + item_size - distance) / (name_size + item_size) >= 2/3 1 - (2*distance) / (name_size + item_size) >= 2/3 1/3 >= (2*distance) / (name_size + item_size) (name_size + item_size) / 6 >= distance With rounding: (name_size + item_size + 3) // 6 >= distance ``` Co-authored-by: Pablo Galindo <pablogsal@gmail.com> |
||
|---|---|---|
| .. | ||
| cpython | ||
| internal | ||
| abstract.h | ||
| bltinmodule.h | ||
| boolobject.h | ||
| bytearrayobject.h | ||
| bytesobject.h | ||
| cellobject.h | ||
| ceval.h | ||
| classobject.h | ||
| code.h | ||
| codecs.h | ||
| compile.h | ||
| complexobject.h | ||
| context.h | ||
| datetime.h | ||
| descrobject.h | ||
| dictobject.h | ||
| dynamic_annotations.h | ||
| enumobject.h | ||
| errcode.h | ||
| eval.h | ||
| exports.h | ||
| fileobject.h | ||
| fileutils.h | ||
| floatobject.h | ||
| frameobject.h | ||
| funcobject.h | ||
| genericaliasobject.h | ||
| genobject.h | ||
| import.h | ||
| interpreteridobject.h | ||
| intrcheck.h | ||
| iterobject.h | ||
| listobject.h | ||
| longintrepr.h | ||
| longobject.h | ||
| marshal.h | ||
| memoryobject.h | ||
| methodobject.h | ||
| modsupport.h | ||
| moduleobject.h | ||
| namespaceobject.h | ||
| object.h | ||
| objimpl.h | ||
| opcode.h | ||
| osdefs.h | ||
| osmodule.h | ||
| patchlevel.h | ||
| py_curses.h | ||
| pycapsule.h | ||
| pydtrace.d | ||
| pydtrace.h | ||
| pyerrors.h | ||
| pyexpat.h | ||
| pyframe.h | ||
| pyhash.h | ||
| pylifecycle.h | ||
| pymacconfig.h | ||
| pymacro.h | ||
| pymath.h | ||
| pymem.h | ||
| pyport.h | ||
| pystate.h | ||
| pystrcmp.h | ||
| pystrhex.h | ||
| pystrtod.h | ||
| Python.h | ||
| pythonrun.h | ||
| pythread.h | ||
| rangeobject.h | ||
| README.rst | ||
| setobject.h | ||
| sliceobject.h | ||
| structmember.h | ||
| structseq.h | ||
| sysmodule.h | ||
| token.h | ||
| traceback.h | ||
| tracemalloc.h | ||
| tupleobject.h | ||
| typeslots.h | ||
| unicodeobject.h | ||
| warnings.h | ||
| weakrefobject.h | ||
The Python C API ================ The C API is divided into three sections: 1. ``Include/`` 2. ``Include/cpython/`` 3. ``Include/internal/`` Include: Limited API ==================== ``Include/``, excluding the ``cpython`` and ``internal`` subdirectories, contains the public Limited API (Application Programming Interface). The Limited API is a subset of the C API, designed to guarantee ABI stability across Python 3 versions, and is defined in :pep:`384`. Guidelines for expanding the Limited API: - Functions *must not* steal references - Functions *must not* return borrowed references - Functions returning references *must* return a strong reference - Macros should not expose implementation details - Please start a public discussion before expanding the API - Functions or macros with a ``_Py`` prefix do not belong in ``Include/``. It is possible to add a function or macro to the Limited API from a given Python version. For example, to add a function to the Limited API from Python 3.10 and onwards, wrap it with ``#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000``. Include/cpython: CPython implementation details =============================================== ``Include/cpython/`` contains the public API that is excluded from the Limited API and the Stable ABI. Guidelines for expanding the public API: - Functions *must not* steal references - Functions *must not* return borrowed references - Functions returning references *must* return a strong reference Include/internal: The internal API ================================== With PyAPI_FUNC or PyAPI_DATA ----------------------------- Functions or structures in ``Include/internal/`` defined with ``PyAPI_FUNC`` or ``PyAPI_DATA`` are internal functions which are exposed only for specific use cases like debuggers and profilers. With the extern keyword ----------------------- Functions in ``Include/internal/`` defined with the ``extern`` keyword *must not and can not* be used outside the CPython code base. Only built-in stdlib extensions (built with the ``Py_BUILD_CORE_BUILTIN`` macro defined) can use such functions. When in doubt, new internal C functions should be defined in ``Include/internal`` using the ``extern`` keyword.