Skip to content

Structural Decorators

Singleton pattern enforcement.


SingletonClass

Python
SingletonClass(cls: type) -> type

Enforces singleton behavior by wrapping the class in a custom subclass.

Prevents the user-defined class from defining its own __new__, which would conflict with the singleton logic.

RETURNS DESCRIPTION
type

A singleton-enforcing subclass of the original