--- id: plum-dispatch version: "2.9.0" license: MIT license_treatment: permissive maintenance: active --- # plum-dispatch — Multiple dispatch in Python License: permissive · Maintenance: active · Downloads: 1.8M/mo ## 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 above — 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 pip install plum-dispatch uv add plum-dispatch 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_current - Install friction: low - Maintenance: active - Downloads: 1.8M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags multiple dispatch python, function overloading by type, runtime method resolution, type-based function selection, polymorphic function dispatch, single dispatch alternative, julia-style dispatch, type-dispatch, polymorphism, scientific-computing [View on SkillFed](https://skillfed.io/packages/plum-dispatch) · [View on PyPI](https://pypi.org/project/plum-dispatch/)