multiton package

Submodules

multiton.multiton module

Main module.

multiton.multiton.MultitonMetaFactory(*relevant_args, **relevant_kwargs) → Type[CT_co][source]

A function that returns a multiton class which will return a previous instance of a object based of some __init__ attributes. Attributes used for the Multiton need to be Hashable, or you need to provide a callable that gets a Hashable value as a tuple of (key, callable).

Args:
relevant_args (Union[int, Tuple[int, Callable]]): positional arguemnts are indices for the relevant __init__ arguments of your class.
indices can also be a tuple of (index, callable) where callable returns a value of hashable type.
relevant_kwargs (Union[Hashable, Tuple[Hashable, Callable]]): keyword arguments are the keywords for the relevant __init__ keyword arguments of your class.
keyword arguemnts should be None or a callablethat returns a value of hashable type from the keywords value.
Raises:
TypeError: raised for various missing or malformed arguments, or when one of the values is a non-hashable type. type: any error raised by the users callable.
Returns:
MultitonMeta: the metaclass that enforces multiton behaviour.

Module contents

Top-level package for Multiton.