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/
>>> 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'
(int, float)
Iterator, Number, ...
a = arbitrary_type() @dispatch(a, a) def are_same_type(x, y): return True
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.
New BSD. See License file.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4