mixed-methods
Mixed methods.
What it is and what it does
mixed-methods is a small utility library that exports a single decorator, `mixed_method`, which allows you to define a method that behaves as a classmethod when called on the class itself and as an instance method when called on an instance. You pass two functions to the decorator—one for class-level behavior and one for instance-level behavior—and the resulting method dispatches to the appropriate implementation based on how it's invoked.
The package is typed and supports Python 3.8 and above. It has no external dependencies beyond attrs and typing-extensions, making it lightweight. The library is dormant (last updated over 900 days ago) but marked as production-stable; it solves a narrow, well-defined problem and has remained essentially unchanged since its early releases.
Use it for:
- Factory methods that construct instances differently when called on the class versus operating on an existing instance
- Dual-mode utilities where class-level calls perform setup or configuration and instance calls perform operations
- Avoiding name collisions when you need both a classmethod and instance method with identical names
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a decorator that lets a single method behave differently when called on a class versus an instance, combining classmethod and instance method logic in one.
Yes, if you specifically need a method that behaves as both classmethod and instance method. The package is lightweight, permissively licensed, and solves its narrow problem cleanly. However, dormant maintenance and minimal download volume suggest it remains a niche utility; only install if this exact pattern fits your design.
Install
mixed-methods on PyPI
pip
pip install mixed-methodsuv
uv add mixed-methodspoetry
poetry add mixed-methodsInstalling mixed-methods
Before you install
Low friction install with only two lightweight runtime dependencies (attrs and typing-extensions). Maintenance is dormant—last release was over 900 days ago and the repository shows minimal activity, though it remains unarchived and marked production-stable.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install mixed-methods
from mixed_methods import mixed_method
class Type:
@classmethod
def type_method(cls) -> int:
return 13
def instance_method(self) -> int:
return 42
method = mixed_method(type_method, instance_method)
Type.method() # returns 13
instance = Type()
instance.method() # returns 42
Requires Python 3.8 or above.
Verify before relying
- Whether the package handles edge cases like inheritance, property interaction, or descriptor protocol conflicts
- Performance characteristics when mixed methods are called in tight loops or hot code paths
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — attrs, typing-extensions |
| Maintenance | dormant — 900 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 77,688/month — #14,506 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mixed_methods-1.1.1-py3-none-any.whl
Keywords: python, mixed, method
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
multimethodMultimethod provides a decorator for adding…
permissive · top 5,000 on PyPI
wrapsProvides type-safe wrapper types for…
permissive · top 15,000 on PyPI
orderingsProvides an Ordering enumeration and Compare…
permissive · top 15,000 on PyPI
solusProvides thread-safe and thread-unsafe…
permissive · top 15,000 on PyPI
wireropeWraps Python callables (functions and methods)…
permissive · top 5,000 on PyPI
namedProvides utilities to inspect and work with…
permissive · top 15,000 on PyPI
methodtoolsProvides LRU caching for methods, classmethods,…
permissive · top 5,000 on PyPI
entrypointProvides a decorator to mark functions as entry…
permissive · top 15,000 on PyPI
singleton-decoratorProvides a decorator that enforces singleton…
copyleft · top 15,000 on PyPI
forbiddenfruitForbiddenfruit allows you to dynamically add…
unclear · top 5,000 on PyPI