[Python-checkins] cpython: moved the single-dispatch generic function definitions to the glossary

lukasz.langa python-checkins at python.org
Fri Jun 7 22:54:38 CEST 2013


http://hg.python.org/cpython/rev/42519153cb08
changeset:   84054:42519153cb08
user:        Łukasz Langa <lukasz at langa.pl>
date:        Fri Jun 07 22:54:03 2013 +0200
summary:
  moved the single-dispatch generic function definitions to the glossary

files:
  Doc/glossary.rst          |  13 +++++++++++++
  Doc/library/functools.rst |   8 ++------
  2 files changed, 15 insertions(+), 6 deletions(-)


diff --git a/Doc/glossary.rst b/Doc/glossary.rst
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -302,6 +302,15 @@
          >>> sum(i*i for i in range(10))         # sum of squares 0, 1, 4, ... 81
          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.
+
+      See also the :term:`single dispatch` glossary entry, the
+      :func:`functools.singledispatch` decorator, and :pep:`443`.
+
+
    GIL
       See :term:`global interpreter lock`.
 
@@ -745,6 +754,10 @@
       mapping rather than a sequence because the lookups use arbitrary
       :term:`immutable` keys rather than integers.
 
+   single dispatch
+      A form of :term:`generic function` dispatch where the implementation is
+      chosen based on the type of a single argument.
+
    slice
       An object usually containing a portion of a :term:`sequence`.  A slice is
       created using the subscript notation, ``[]`` with colons between numbers
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -189,12 +189,8 @@
 
 .. decorator:: singledispatch(default)
 
-   Transforms a function into a single-dispatch generic function.  A **generic
-   function** is 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.  When the implementation is chosen
-   based on the type of a single argument, this is known as **single
-   dispatch**.
+   Transforms a function into a :term:`single-dispatch <single
+   dispatch>` :term:`generic function`.
 
    To define a generic function, decorate it with the ``@singledispatch``
    decorator. Note that the dispatch happens on the type of the first argument,

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list