From 40f5ac89e411fe0a32e619985983995929ad22e9 Mon Sep 17 00:00:00 2001 From: Dmitry Voropaev Date: Thu, 24 Sep 2026 23:54:52 +0300 Subject: [PATCH] gh-110195: Note both meanings of "generic function" in the glossary The glossary defined the term only as the functools.singledispatch kind of function, but the language reference uses the same name for a function parameterized by type variables. Split the entry so that each meaning points at its own documentation, and describe the second one by what it does rather than by the PEP 695 syntax alone, since the older typing.TypeVar spelling means the same thing. The dispatch wording is word for word what it was; its lines are rewrapped only because the text now sits two columns further in. --- Doc/glossary.rst | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 68bc0560911161..54b8d1198420d3 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -692,12 +692,25 @@ Glossary 285 generic function - A function composed of multiple functions implementing the same operation - for different types. Which implementation should be used during a call is - determined by the dispatch algorithm. + This term has two distinct meanings: - See also the :term:`single dispatch` glossary entry, the - :deco:`functools.singledispatch` decorator, and :pep:`443`. + * A function composed of multiple functions implementing the same + operation for different types. Which implementation should be used + during a call is determined by the dispatch algorithm. + + See also the :term:`single dispatch` glossary entry, the + :deco:`functools.singledispatch` decorator, and :pep:`443`. + + * A function parameterized by one or more type variables, so that it + can be used with many types while a :term:`static type checker` + still tracks how the types of its arguments relate to the type of + its return value. Such a function is usually declared with a + :ref:`type parameter list `, as in + ``def first[T](values: list[T]) -> T: ...``; it can also be written + with explicit :class:`typing.TypeVar` objects, which was the only + way before Python 3.12. + + See :ref:`generic-functions` and :pep:`695`. generic type A :term:`type` that can be parameterized; typically a