multipledispatch


Namemultipledispatch JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttp://github.com/mrocklin/multipledispatch/
SummaryMultiple dispatch
upload_time2023-06-27 16:45:11
maintainer
docs_urlNone
authorMatthew Rocklin
requires_python
licenseBSD
keywords dispatch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Multiple Dispatch
=================

|Build Status| |Coverage Status| |Version Status|

A relatively sane approach to multiple dispatch in Python.

This implementation of multiple dispatch is efficient, mostly complete,
performs static analysis to avoid conflicts, and provides optional namespace
support.  It looks good too.

See the documentation at https://multiple-dispatch.readthedocs.io/


Example
-------

.. code-block:: python

   >>> from multipledispatch import dispatch

   >>> @dispatch(int, int)
   ... def add(x, y):
   ...     return x + y

   >>> @dispatch(object, object)
   ... def add(x, y):
   ...     return "%s + %s" % (x, y)

   >>> add(1, 2)
   3

   >>> add(1, 'hello')
   '1 + hello'

What this does
--------------

-  Dispatches on all non-keyword arguments

-  Supports inheritance

-  Supports instance methods

-  Supports union types, e.g. ``(int, float)``

-  Supports builtin abstract classes, e.g. ``Iterator, Number, ...``

-  Caches for fast repeated lookup

-  Identifies possible ambiguities at function definition time

-  Provides hints to resolve ambiguities when they occur

-  Supports namespaces with optional keyword arguments

-  Supports variadic dispatch

What this doesn't do
--------------------

-  Diagonal dispatch

.. code-block:: python

   a = arbitrary_type()
   @dispatch(a, a)
   def are_same_type(x, y):
       return True

-  Efficient update: The addition of a new signature requires a full resolve of
   the whole function.  This becomes troublesome after you get to a few hundred
   type signatures.


Installation and Dependencies
-----------------------------

``multipledispatch`` is on the Python Package Index (PyPI):

::

    pip install multipledispatch

It is Pure-Python and depends only on the standard library.
It is a light weight dependency.


License
-------

New BSD. See `License file`_.


Links
-----

-  `Five-minute Multimethods in Python by Guido`_
-  `multimethods package on PyPI`_
-  `singledispatch in Python 3.4's functools`_
-  `Clojure Protocols`_
-  `Julia methods docs`_
-  `Karpinksi notebook: *The Design Impact of Multiple Dispatch*`_
-  `Wikipedia article`_
-  `PEP 3124 - *Overloading, Generic Functions, Interfaces, and Adaptation*`_


.. _`Five-minute Multimethods in Python by Guido`:
  http://www.artima.com/weblogs/viewpost.jsp?thread=101605
.. _`multimethods package on PyPI`:
  https://pypi.python.org/pypi/multimethods
.. _`singledispatch in Python 3.4's functools`:
  http://docs.python.org/3.4/library/functools.html#functools.singledispatch
.. _`Clojure Protocols`:
  http://clojure.org/protocols
.. _`Julia methods docs`:
  https://docs.julialang.org/en/v1/manual/methods/
.. _`Karpinksi notebook: *The Design Impact of Multiple Dispatch*`:
  http://nbviewer.ipython.org/gist/StefanKarpinski/b8fe9dbb36c1427b9f22
.. _`Wikipedia article`:
  http://en.wikipedia.org/wiki/Multiple_dispatch
.. _`PEP 3124 - *Overloading, Generic Functions, Interfaces, and Adaptation*`:
  http://legacy.python.org/dev/peps/pep-3124/

.. |Build Status| image:: https://travis-ci.org/mrocklin/multipledispatch.svg
   :target: https://travis-ci.org/mrocklin/multipledispatch
.. |Version Status| image:: https://pypip.in/v/multipledispatch/badge.svg
   :target: https://img.shields.io/pypi/v/multipledispatch.svg
.. |Coverage Status| image:: https://coveralls.io/repos/mrocklin/multipledispatch/badge.svg
   :target: https://coveralls.io/r/mrocklin/multipledispatch
.. _License file: https://github.com/mrocklin/multipledispatch/blob/master/LICENSE.txt

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/mrocklin/multipledispatch/",
    "name": "multipledispatch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "dispatch",
    "author": "Matthew Rocklin",
    "author_email": "mrocklin@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fe/3e/a62c3b824c7dec33c4a1578bcc842e6c30300051033a4e5975ed86cc2536/multipledispatch-1.0.0.tar.gz",
    "platform": null,
    "description": "Multiple Dispatch\n=================\n\n|Build Status| |Coverage Status| |Version Status|\n\nA relatively sane approach to multiple dispatch in Python.\n\nThis implementation of multiple dispatch is efficient, mostly complete,\nperforms static analysis to avoid conflicts, and provides optional namespace\nsupport.  It looks good too.\n\nSee the documentation at https://multiple-dispatch.readthedocs.io/\n\n\nExample\n-------\n\n.. code-block:: python\n\n   >>> from multipledispatch import dispatch\n\n   >>> @dispatch(int, int)\n   ... def add(x, y):\n   ...     return x + y\n\n   >>> @dispatch(object, object)\n   ... def add(x, y):\n   ...     return \"%s + %s\" % (x, y)\n\n   >>> add(1, 2)\n   3\n\n   >>> add(1, 'hello')\n   '1 + hello'\n\nWhat this does\n--------------\n\n-  Dispatches on all non-keyword arguments\n\n-  Supports inheritance\n\n-  Supports instance methods\n\n-  Supports union types, e.g. ``(int, float)``\n\n-  Supports builtin abstract classes, e.g. ``Iterator, Number, ...``\n\n-  Caches for fast repeated lookup\n\n-  Identifies possible ambiguities at function definition time\n\n-  Provides hints to resolve ambiguities when they occur\n\n-  Supports namespaces with optional keyword arguments\n\n-  Supports variadic dispatch\n\nWhat this doesn't do\n--------------------\n\n-  Diagonal dispatch\n\n.. code-block:: python\n\n   a = arbitrary_type()\n   @dispatch(a, a)\n   def are_same_type(x, y):\n       return True\n\n-  Efficient update: The addition of a new signature requires a full resolve of\n   the whole function.  This becomes troublesome after you get to a few hundred\n   type signatures.\n\n\nInstallation and Dependencies\n-----------------------------\n\n``multipledispatch`` is on the Python Package Index (PyPI):\n\n::\n\n    pip install multipledispatch\n\nIt is Pure-Python and depends only on the standard library.\nIt is a light weight dependency.\n\n\nLicense\n-------\n\nNew BSD. See `License file`_.\n\n\nLinks\n-----\n\n-  `Five-minute Multimethods in Python by Guido`_\n-  `multimethods package on PyPI`_\n-  `singledispatch in Python 3.4's functools`_\n-  `Clojure Protocols`_\n-  `Julia methods docs`_\n-  `Karpinksi notebook: *The Design Impact of Multiple Dispatch*`_\n-  `Wikipedia article`_\n-  `PEP 3124 - *Overloading, Generic Functions, Interfaces, and Adaptation*`_\n\n\n.. _`Five-minute Multimethods in Python by Guido`:\n  http://www.artima.com/weblogs/viewpost.jsp?thread=101605\n.. _`multimethods package on PyPI`:\n  https://pypi.python.org/pypi/multimethods\n.. _`singledispatch in Python 3.4's functools`:\n  http://docs.python.org/3.4/library/functools.html#functools.singledispatch\n.. _`Clojure Protocols`:\n  http://clojure.org/protocols\n.. _`Julia methods docs`:\n  https://docs.julialang.org/en/v1/manual/methods/\n.. _`Karpinksi notebook: *The Design Impact of Multiple Dispatch*`:\n  http://nbviewer.ipython.org/gist/StefanKarpinski/b8fe9dbb36c1427b9f22\n.. _`Wikipedia article`:\n  http://en.wikipedia.org/wiki/Multiple_dispatch\n.. _`PEP 3124 - *Overloading, Generic Functions, Interfaces, and Adaptation*`:\n  http://legacy.python.org/dev/peps/pep-3124/\n\n.. |Build Status| image:: https://travis-ci.org/mrocklin/multipledispatch.svg\n   :target: https://travis-ci.org/mrocklin/multipledispatch\n.. |Version Status| image:: https://pypip.in/v/multipledispatch/badge.svg\n   :target: https://img.shields.io/pypi/v/multipledispatch.svg\n.. |Coverage Status| image:: https://coveralls.io/repos/mrocklin/multipledispatch/badge.svg\n   :target: https://coveralls.io/r/mrocklin/multipledispatch\n.. _License file: https://github.com/mrocklin/multipledispatch/blob/master/LICENSE.txt\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Multiple dispatch",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "http://github.com/mrocklin/multipledispatch/"
    },
    "split_keywords": [
        "dispatch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "51c000c9809d8b9346eb238a6bbd5f83e846a4ce4503da94a4c08cb7284c325b",
                "md5": "6adfcc1198cffc4c5a5abdcff7aa463e",
                "sha256": "0c53cd8b077546da4e48869f49b13164bebafd0c2a5afceb6bb6a316e7fb46e4"
            },
            "downloads": -1,
            "filename": "multipledispatch-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6adfcc1198cffc4c5a5abdcff7aa463e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12818,
            "upload_time": "2023-06-27T16:45:09",
            "upload_time_iso_8601": "2023-06-27T16:45:09.418840Z",
            "url": "https://files.pythonhosted.org/packages/51/c0/00c9809d8b9346eb238a6bbd5f83e846a4ce4503da94a4c08cb7284c325b/multipledispatch-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe3ea62c3b824c7dec33c4a1578bcc842e6c30300051033a4e5975ed86cc2536",
                "md5": "e2c12d5aaf368e8f2e9c7535c0ce5b74",
                "sha256": "5c839915465c68206c3e9c473357908216c28383b425361e5d144594bf85a7e0"
            },
            "downloads": -1,
            "filename": "multipledispatch-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e2c12d5aaf368e8f2e9c7535c0ce5b74",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12385,
            "upload_time": "2023-06-27T16:45:11",
            "upload_time_iso_8601": "2023-06-27T16:45:11.074927Z",
            "url": "https://files.pythonhosted.org/packages/fe/3e/a62c3b824c7dec33c4a1578bcc842e6c30300051033a4e5975ed86cc2536/multipledispatch-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-27 16:45:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mrocklin",
    "github_project": "multipledispatch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "multipledispatch"
}
        
Elapsed time: 0.08776s