skillfed

phx-class-registry

Factory+Registry pattern for Python classes

phx-class-registry v5.2.2 145.9K downloads/30d#11,114 on PyPI57
Permissive license MIT Active released

What it is and what it does

phx-class-registry provides a lightweight implementation of the Registry and Factory design patterns for Python. It lets you create a registry object, decorate classes to register them under string keys, and then instantiate those classes by key lookup. The pattern is useful for plugin systems, service locators, and any scenario where you need to dynamically select and instantiate classes at runtime based on configuration or user input.

The package supports advanced features including passing constructor arguments, automatic registration of non-abstract classes, and integration with setuptools entry points to allow third-party libraries to extend your registries. With zero runtime dependencies and active maintenance, it's a straightforward tool for implementing these patterns without external complexity.

Use it for:

  • Build a plugin system where third-party packages register handlers via entry points.
  • Create a service registry that maps service names to their implementation classes.
  • Implement a factory for different data processor classes selected by file type or format.
  • Define a registry of database drivers or connection strategies keyed by database name.
  • Build a command dispatcher that maps command strings to handler classes.
  • Create a polymorphic object instantiation system for configuration-driven class selection.

Worth the install?

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

Implements the Registry and Factory patterns to create configurable class registries that map keys to class constructors, with optional integration into setuptools entry points for third-party extensibility.

Yes. The package is actively maintained, has zero security vulnerabilities, imposes no dependency overhead, and cleanly solves a common architectural problem. It is worth installing if you need to implement registry or factory patterns in your application. The MIT license removes any legal friction. The only constraint is the Python 3.12 or later requirement.

Install

phx-class-registry on PyPI

pip

pip install phx-class-registry

uv

uv add phx-class-registry

poetry

poetry add phx-class-registry

Installing phx-class-registry

Before you install

Low install friction with no runtime dependencies. Active maintenance with a recent release 94 days ago and ongoing repository activity. Requires Python 3.12 or later.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and proprietary projects.

Quickstart

pip install phx-class-registry

from phx_class_registry import ClassRegistry

pokedex = ClassRegistry()

@pokedex.register('fire')
class Charizard:
    pass

fighter = pokedex['fire']

Requires Python 3.12 or later.

Verify before relying

  • Whether the package supports type hints for registry instances in practice across all supported Python versions.
  • Performance characteristics when registries contain hundreds or thousands of registered classes.
  • Exact behavior and compatibility of entry_points integration with modern setuptools versions.

Package facts

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

Evidence: phx_class_registry-5.2.2-py3-none-any.whl

Keywords: design pattern, factory pattern, registry pattern, service registry

Development Status :: 5 - Production/StableIntended Audience :: DevelopersTopic :: Software Development :: Libraries :: Python Modules

Tags

registry pattern pythonfactory pattern implementationclass registry decoratordynamic class instantiationservice registry patternplugin registry systementry points integration
design-patternsplugin-systemfactory-pattern

More Python Modules packages