skillfed

mixed-methods

Mixed methods.

mixed-methods v1.1.1 77.7K downloads/30d#14,506 on PyPI1
Permissive license MIT DORMANT released

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

uv

uv add mixed-methods

poetry

poetry add mixed-methods

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: UtilitiesTyping :: Typed

Tags

mixed method decoratorclassmethod instance method combineddual behavior method pythonclass and instance method same namepolymorphic method decorator
decoratormethod-dispatch

More Utilities packages