Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fdcf2b7

Browse files
committed
moved the single-dispatch generic function definitions to the glossary
1 parent 7f7a67a commit fdcf2b7

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

Doc/glossary.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ Glossary
302302
>>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81
303303
285
304304

305+
generic function
306+
A function composed of multiple functions implementing the same operation
307+
for different types. Which implementation should be used during a call is
308+
determined by the dispatch algorithm.
309+
310+
See also the :term:`single dispatch` glossary entry, the
311+
:func:`functools.singledispatch` decorator, and :pep:`443`.
312+
313+
305314
GIL
306315
See :term:`global interpreter lock`.
307316

@@ -745,6 +754,10 @@ Glossary
745754
mapping rather than a sequence because the lookups use arbitrary
746755
:term:`immutable` keys rather than integers.
747756

757+
single dispatch
758+
A form of :term:`generic function` dispatch where the implementation is
759+
chosen based on the type of a single argument.
760+
748761
slice
749762
An object usually containing a portion of a :term:`sequence`. A slice is
750763
created using the subscript notation, ``[]`` with colons between numbers

Doc/library/functools.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,8 @@ The :mod:`functools` module defines the following functions:
189189

190190
.. decorator:: singledispatch(default)
191191

192-
Transforms a function into a single-dispatch generic function. A **generic
193-
function** is composed of multiple functions implementing the same operation
194-
for different types. Which implementation should be used during a call is
195-
determined by the dispatch algorithm. When the implementation is chosen
196-
based on the type of a single argument, this is known as **single
197-
dispatch**.
192+
Transforms a function into a :term:`single-dispatch <single
193+
dispatch>` :term:`generic function`.
198194

199195
To define a generic function, decorate it with the ``@singledispatch``
200196
decorator. Note that the dispatch happens on the type of the first argument,

0 commit comments

Comments
 (0)