skillfed

plum-dispatch

Multiple dispatch in Python

plum-dispatch v2.9.0 1.8M downloads/30d#3,523 on PyPI653
Permissive license MIT Active released

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

uv

uv add plum-dispatch

poetry

poetry add plum-dispatch

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Typing :: Typed

Tags

multiple dispatch pythonfunction overloading by typeruntime method resolutiontype-based function selectionpolymorphic function dispatchsingle dispatch alternativejulia-style dispatch
type-dispatchpolymorphismscientific-computing

More Software Development packages