• Stars
    star
    805
  • Rank 56,629 (Top 2 %)
  • Language
    Python
  • License
    Other
  • Created almost 11 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Multiple dispatch

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

>>> 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
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

or

easy_install multipledispatch

multipledispatch supports Python 2.6+ and Python 3.2+ with a common codebase. It is pure Python and requires only the small six library as a dependency.

It is, in short, a light weight dependency.

License

New BSD. See License file.

Links

More Repositories

1

dask-geopandas

Parallelized GeoPandas with Dask
Python
107
star
2

unification

Python
71
star
3

multipolyfit

A multivariate polynomial regression function in python
Python
55
star
4

pydata-toolz

Tutorial for Funcitonal Python tutorial at PyData-NYC 2013
48
star
5

dasklearn

Dask powered gridsearch and pipeline a la scikit-learn
Python
42
star
6

ShallowWater

Simple Python implementation of Shallow Water Equations
Python
42
star
7

pymarkdown

Evaluate code in markdown
HTML
42
star
8

heft

A static scheduling heuristic
Python
41
star
9

arxiv-matplotlib

Jupyter Notebook
37
star
10

pydata-nyc-2018-tutorial

Jupyter Notebook
37
star
11

fakestockdata

Generate fake stock data for testing or teaching
Python
31
star
12

dask-workshop

Jupyter Notebook
28
star
13

matrix-algebra

An algebra for Matrix Expressions written in Maude
23
star
14

slides

A template for slides using markdown
Python
21
star
15

dask-spark

Dask and Spark interactions
Python
21
star
16

chest

Simple spill-to-disk dictionary
Python
18
star
17

dask-tutorial

Jupyter Notebook
17
star
18

tompkins

A static DAG scheduling algorithm for heterogeneous systems using Mixed Integer Linear Programming . Implementation of "Optimization Techniques for Task Allocation and Scheduling in Distributed Multi-Agent Operations."
Python
16
star
19

blaze-tutorial

12
star
20

blog

Matthew Rocklin's technical blog
HTML
11
star
21

dask-marathon

Deploy Dask on Marathon
Python
10
star
22

itertoolz

More tools for iterators
Python
9
star
23

tutorials

A collection of executable tutorials from SciPy and PyData conferences
Python
8
star
24

dask-gpu-benchmarks

Jupyter Notebook
7
star
25

classtoolz

A collection of mixin classes
Python
7
star
26

cv

Curriculum Vita / Resume
TeX
7
star
27

mrocklin.github.io

Professional webpage
HTML
6
star
28

functoolz

More tools for functions
Python
6
star
29

ape

Research project on scheduling array primitives
Python
6
star
30

blaze-scipy-2014

Slides for scipy 2014 conference
6
star
31

computations

Python
5
star
32

intrograph

Organize computations through introspection of function argument names
Python
5
star
33

ctypes-example

A very simple example calling C code from within Python
Python
5
star
34

dask-mesos

Python
4
star
35

symbolic-array

Symbolic Numpy Arrays
Python
4
star
36

cmsc15200

A course webpage for CMSC15200 Summer 2012
C
3
star
37

shmarray

Python
3
star
38

dist

Python
3
star
39

thesis

TeX
3
star
40

cise-sympy-stats

Scripts to generate figures and equations in CiSE article "Symbolic Statistics with SymPy"
Python
3
star
41

skimage-dask-blog

Blogpost describing scikit-image and dask.array interaction
2
star
42

dask-demo

Live Demonstrations of Using Dask on Kubernetes
Jupyter Notebook
2
star
43

immigrants-are-awesome

Static site with information about American immigrants
HTML
2
star
44

seg-2019

Notebooks for a talk at SEG
Jupyter Notebook
2
star
45

dask-crossval

Python
2
star
46

unify

Unification algorithm for list-based trees
Python
2
star
47

termpy

Python
2
star
48

gha

GitHub Analysis
Python
2
star
49

dask-webinar-2018-11

Jupyter Notebook
2
star
50

opcounts

FLOPs for sequential BLAS and LAPACK libraries
Python
2
star
51

pangeo-binder-test

Jupyter Notebook
1
star
52

tprofile

Python
1
star
53

conda-forge-dependencies

Jupyter Notebook
1
star
54

cmsc10200

Class Teaching Materials for CMSC10200
Python
1
star
55

demo-binder

Jupyter Notebook
1
star
56

hpfrisbee

A website for a community Ultimate Frisbee game.
1
star
57

alettertofaye

A letter about basic computer security
1
star
58

test-project

1
star
59

nyc-taxi

Fooling around with NYC Taxi data
Jupyter Notebook
1
star
60

raw-host

HTML
1
star
61

zdict

Useful Mutable Mappings
1
star
62

dask-webpage

temporary hosting while screwing around with a basic webpage
HTML
1
star
63

mailFeed

Python code to access incoming mail from a gmail account
Python
1
star
64

helm-charts

1
star
65

py32test

A demonstration using Cython to backport a Python 3 codebase
Python
1
star
66

cva-example

Python
1
star