lazysignals._utils

Classes

SingletonMeta

A metaclass for creating singleton classes.

Functions

is_added(s, x)

Adds an element to a set and returns if it was not already present.

Module Contents

class SingletonMeta

Bases: type

A metaclass for creating singleton classes.

This metaclass ensures that only one instance of a class is created, and that all subsequent calls to the constructor return the same instance.

_instances
__call__(*args, **kwargs)

Create and store a new instance of the class if it doesn’t exist yet, or return the existing instance.

is_added(s, x)

Adds an element to a set and returns if it was not already present.

Parameters:
  • s – The set to add the element to.

  • x – The element to add.

Returns:

True if x was not in s, False otherwise.