plum-dispatch
Multiple dispatch in Python
What it is and what it does
Plum brings type annotations to life by implementing multiple dispatch—a pattern where a single function name can have multiple implementations, each handling different argument types. When you call the function, Plum examines the types of the positional arguments and selects the most specific matching implementation. This is inspired by Julia's dispatch model and differs from Python's built-in single dispatch by supporting multiple arguments and type hierarchies.
The package is powered by beartype and depends on rich and typing-extensions. It works with type hierarchies (e.g., Number, Real, Rational) and automatically selects the best-matching implementation when arguments span multiple types. A key constraint: dispatch decisions are based only on positional arguments, not keyword arguments, so arguments without defaults must always be passed positionally.
Use it for:
- Implement backend-agnostic libraries that handle multiple array types with specialized code paths for each
- Build scientific computing libraries where operations differ based on numeric types (integers, reals, complex numbers)
- Create extensible data processing pipelines where different data types trigger different processing strategies
- Design machine learning frameworks that need to dispatch to optimized implementations based on input types
- Develop coordinate or geometry systems where operations vary by coordinate system or dimension type
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Plum implements multiple dispatch in Python, allowing you to define multiple implementations of a function that are selected at runtime based on the types of positional arguments.
Yes. Plum is actively maintained, has no security vulnerabilities, uses a permissive MIT license, and installs with low friction. It is appropriate for projects that need clean, type-driven polymorphism—particularly scientific computing, machine learning, and backend-agnostic libraries. The Python 3.10 or higher requirement is a hard constraint; if you need older Python support, this is not an option.
Install
plum-dispatch on PyPI
pip
pip install plum-dispatchuv
uv add plum-dispatchpoetry
poetry add plum-dispatchInstalling plum-dispatch
Before you install
Low friction install with three runtime dependencies (beartype, rich, typing-extensions). The package is actively maintained with a recent release and no known vulnerabilities, though it requires Python 3.10 or higher.
License in practice
MIT license is permissive and imposes no significant restrictions on use, modification, or distribution in commercial or private projects.
Quickstart
pip install plum-dispatch
from plum import dispatch
@dispatch
def f(x: str):
return "This is a string!"
@dispatch
def f(x: int):
return "This is an integer!"
f("1") # 'This is a string!'
f(1) # 'This is an integer!'
Requires Python 3.10 or higher. Dispatch decisions are based only on positional arguments; arguments without defaults must always be passed positionally, not as keyword arguments.
Verify before relying
- Performance characteristics compared to other multiple dispatch implementations in typical workloads
- Whether keyword-only dispatch or mixed positional-keyword patterns are planned for future releases
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — beartype, rich, typing-extensions |
| Maintenance | actively maintained — 108 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,815,888/month — #3,523 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: plum_dispatch-2.9.0-py3-none-any.whl
Keywords: multiple, dispatch
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
overloadingProvides function and method overloading based…
permissive · top 15,000 on PyPI
multipledispatchEnables functions to dispatch on the types of…
permissive · top 5,000 on PyPI
ovldOvld provides fast multiple dispatch for Python…
permissive · top 15,000 on PyPI
classesImplements typeclasses for Python, enabling…
permissive · top 15,000 on PyPI
pyversPyvers provides dynamic dispatch for Python…
permissive · top 5,000 on PyPI
runtypeRuntype provides runtime type validation,…
permissive · top 15,000 on PyPI
multimethodMultimethod provides a decorator for adding…
permissive · top 5,000 on PyPI
fasttransformfasttransform provides a Transform class for…
permissive · top 15,000 on PyPI
tree-sitter-juliaProvides incremental parsing of Julia source…
permissive · top 5,000 on PyPI
plum-pyTransforms byte sequences into Python objects…
permissive · top 15,000 on PyPI