--- id: simplegeneric version: "0.8.1" license: ZPL 2.1 license_treatment: unclear maintenance: abandoned --- # simplegeneric — Simple generic functions (similar to Python's own len(), pickle.dump(), etc.) License: unclear · Maintenance: abandoned · Downloads: 561.4K/mo ## What it is and what it does simplegeneric is a minimal single-dispatch generic function library that lets you define functions that behave differently based on the type or identity of their first argument. You decorate a base function with @generic, then register type-specific or object-specific implementations using @func.when_type() or @func.when_object() decorators. When the function is called, it looks up and invokes the appropriate implementation based on the argument's type, falling back to the default if no match is found. The library is intentionally simple—under 100 lines of code with no dependencies—and uses lookup tables similar to pickle.dump() and other standard library generic functions. It supports inheritance (methods defined for supertypes are inherited via MRO), multiple type/object registration in a single decorator, and inspection methods like has_type() and has_object(). However, it is abandoned (last release April 2012) and predates Python's built-in functools.singledispatch by several years. Use it for: - Implementing a visitor-like pattern where different object types need different handling without modifying the objects themselves. - Creating a simple type-based dispatch system for serialization, formatting, or conversion routines. - Building extensible functions where new type handlers can be registered at runtime without changing the core function. - Legacy codebases that already depend on simplegeneric and cannot easily migrate to functools.singledispatch. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides a lightweight decorator-based system for defining single-dispatch generic functions that route calls based on the type or identity of their first argument. No. The package is abandoned (no maintenance since 2012) and its Python 3 support is undocumented and untested. Modern Python (3.4+) includes functools.singledispatch, which is actively maintained and serves the same purpose. The unclear license treatment and high install friction add further risk. Install only if you are maintaining legacy code that already depends on it and cannot migrate to functools.singledispatch. ## Install pip install simplegeneric uv add simplegeneric poetry add simplegeneric ## Installing simplegeneric Before you install: High install friction due to source distribution format. Package is abandoned (last release 2012-04-01, no maintenance for 5248 days) and carries only Python 2 classifiers despite claiming Python 3 compatibility in its description. License in practice: Licensed under Zope Public License 2.1 (ZPL 2.1), but license treatment is marked unclear—verify compatibility with your project's license requirements before use. Quickstart: from simplegeneric import generic @generic def process(item): return "default" @process.when_type(int) def _(item): return f"integer: {item}" print(process(42)) # integer: 42 print(process("text")) # default Package is abandoned and has not been maintained since 2012; Python 3 support is undocumented and untested in the repository. Verify before relying: - Whether Python 3 compatibility actually works as claimed in the description, given the package's age and lack of maintenance. - Current status of ZPL 2.1 license compatibility with modern open-source projects and commercial use. - Whether the package's single-dispatch model is sufficient for modern use cases or if functools.singledispatch (Python 3.4+) is a better alternative. ## Package facts - License: ZPL 2.1 (unclear) - Python support: unspecified - Install friction: high - Maintenance: abandoned - Downloads: 561.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags single dispatch generic functions, type-based function dispatch, generic function decorator, method registration by type, visitor pattern alternative, abandoned, legacy, dispatch [View on SkillFed](https://skillfed.io/packages/simplegeneric) · [View on PyPI](https://pypi.org/project/simplegeneric/)