pyvers
A Python library for managing multiple versions of dependencies
Decision gist · record as of 2026-08-14
Yes. Pyvers solves a real problem—managing version-specific code paths—with a clean, low-friction API and zero runtime dependencies. It's actively maintained, supports modern Python versions, has no known vulnerabilities, and is permissively licensed. Install it if you maintain a library that needs to support multiple versions of a dependency or multiple backend implementations.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with no runtime dependencies.
- Active maintenance as of 36 days ago.
- Supports Python 3.9 through 3.14.
License · maintenance · safety
MIT (permissive) — MIT license (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2026-07-09 (36 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,474,161 downloads/mo, #3,047 on PyPI
Alternatives
Verify before relying
from pyvers import implement_for, register_backend, get_backend
register_backend(group="numpy", backends={"numpy": "numpy"})
@implement_for("numpy")
def create_mask(arr):
raise NotImplementedError("No matching numpy version found")
@create_mask.register(from_version=None, to_version="2.0.0")
def _(arr):
np = get_backend("numpy")
return np.array([x > 0 for x in arr], dtype=np.bool8)
@create_mask.register(from_version="2.0.0")
def _(arr):
np = get_backend("numpy")
return np.array([x > 0 for x in arr], dtype=np.bool_)- Whether the package handles edge cases like missing or incompatible backend packages gracefully
- Performance overhead of the dispatch mechanism compared to direct function calls
- Whether version range matching supports pre-release or development versions
What it is and what it does
Pyvers is a dispatch library that lets you write version-aware code without littering your codebase with version checks and conditional logic. It works by registering version-specific implementations of a function, then automatically selecting the correct one based on the installed version of a dependency. You define a base function with the @implement_for decorator, then register variants for different version ranges using the .register() API (similar to functools.singledispatch). At runtime, pyvers inspects the actual installed version and calls the matching implementation.
The library also supports backend switching, letting you register multiple implementations (e.g., NumPy vs JAX, CPU vs GPU) and swap between them dynamically using context managers. Backends are imported only when needed, so you can register optional dependencies without requiring them to be installed upfront. This is useful for libraries that want to support multiple compute backends or handle breaking changes across major versions without forcing users to maintain separate code paths.
Use it for
- Support multiple versions of a dependency (e.g., NumPy < 2.0 vs >= 2.0) without if/else chains in your code
- Switch between CPU (SciPy) and GPU (CuPy) implementations at runtime based on availability or user preference
- Handle breaking API changes in frameworks like PyTorch 2.0 or gymnasium vs gym without duplicating logic
- Write version-specific optimizations (e.g., torch.compile for PyTorch 2.0+) that degrade gracefully on older versions
- Maintain backward compatibility while adopting new library features as they become available
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Pyvers solves a real problem—managing version-specific code paths—with a clean, low-friction API and zero runtime dependencies. It's actively maintained, supports modern Python versions, has no known vulnerabilities, and is permissively licensed. Install it if you maintain a library that needs to support multiple versions of a dependency or multiple backend implementations.
Install
pyvers on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance as of 36 days ago. Supports Python 3.9 through 3.14.
License in practice
MIT license (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
from pyvers import implement_for, register_backend, get_backend
register_backend(group="numpy", backends={"numpy": "numpy"})
@implement_for("numpy")
def create_mask(arr):
raise NotImplementedError("No matching numpy version found")
@create_mask.register(from_version=None, to_version="2.0.0")
def _(arr):
np = get_backend("numpy")
return np.array([x > 0 for x in arr], dtype=np.bool8)
@create_mask.register(from_version="2.0.0")
def _(arr):
np = get_backend("numpy")
return np.array([x > 0 for x in arr], dtype=np.bool_)
Verify before relying
- Whether the package handles edge cases like missing or incompatible backend packages gracefully
- Performance overhead of the dispatch mechanism compared to direct function calls
- Whether version range matching supports pre-release or development versions
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 36 days since the last release |
| First released | |
| Downloads | 2,474,161 / month, #3,047 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9 |
Evidence: pyvers-0.2.3-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “version-based function dispatch”
- pyversPyvers provides dynamic dispatch for Python functions based on…
- plum-dispatchPlum implements multiple dispatch in Python, allowing you to define…
- ovldOvld provides fast multiple dispatch for Python functions, allowing…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also multimethod · singledispatch · autoray · methoddispatch · plum-dispatch · multipledispatch · array-api-compat · jax-jumpy · qpsolvers · pyro-api