skillfed

ovld

Overloading Python functions

ovld v0.5.17 587.0K downloads/30d#5,878 on PyPI398
Permissive license MIT Active released

What it is and what it does

Ovld is a multiple dispatch library that lets you write separate function implementations for different type signatures, selected automatically at runtime based on argument types. Instead of writing nested isinstance checks or using Python's built-in singledispatch (which only works on the first argument), you annotate each version of your function with its type signature and ovld routes calls to the right implementation.

The library handles single and multiple arguments, supports value-based dispatch through Literal types and custom dependent types, and works with methods via metaclasses or base classes. It also provides variants (specialized copies of a function) and medleys (composable mixin-like classes), making it useful for recursive data structure traversal, serialization, and other polymorphic patterns.

Use it for:

  • Implement recursive tree traversal or data structure operations that behave differently for lists, integers, and nested combinations.
  • Build serialization/deserialization logic that handles different types with type-specific code paths.
  • Create mathematical or scientific functions that dispatch on tensor shape, dtype, or other value-dependent properties.
  • Define class methods that behave differently depending on argument types, replacing verbose isinstance chains.
  • Compose reusable function variants that inherit base dispatch logic but override specific type handlers.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Ovld provides fast multiple dispatch for Python functions, allowing you to define separate implementations for different type signatures using type annotations instead of isinstance chains.

Yes. Ovld has no dependencies, installs cleanly, is actively maintained, carries an MIT license with no restrictions, and solves a real problem—writing cleaner polymorphic code than isinstance chains. It's suitable for production use if you need multiple dispatch.

Install

ovld on PyPI

pip

pip install ovld

uv

uv add ovld

poetry

poetry add ovld

Installing ovld

Before you install

Low friction: pure Python wheel with no runtime dependencies. Actively maintained with last commit 2026-05-14.

License in practice

MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions.

Quickstart

from ovld import ovld

@ovld
def f(x: str):
    return f"string: {x}"

@ovld
def f(x: int):
    return f"number: {x}"

print(f("hello"))
print(f(3))

Requires Python 3.9 or later.

Verify before relying

  • Actual performance comparison data against other multiple dispatch libraries
  • Whether value-based dispatch and dependent types work reliably in production at scale
  • Compatibility with type checkers like mypy or pyright for dispatched functions

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 92 days since the last release
Last repo commit
First released
Downloads 586,966/month — #5,878 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: ovld-0.5.17-py3-none-any.whl

Tags

multiple dispatch pythonfunction overloading by typetype-based method selectionruntime type dispatchpolymorphic function callsoverload resolutiondispatch on argument types
polymorphismtype-dispatchfunction-overloading

More Software Development packages