atom.atom module

class atom.atom.Atom[source]

Bases: atom.catom.CAtom

The base class for defining atom objects.

Atom objects are special Python objects which never allocate an instance dictionary unless one is explicitly requested. The storage for an atom is instead computed from the Member objects declared on the class. Memory is reserved for these members with no over allocation.

This restriction make atom objects a bit less flexible than normal Python objects, but they are between 3x-10x more memory efficient than normal objects depending on the number of attributes.

classmethod members() Dict[str, atom.catom.Member][source]

Get the members dictionary for the type.


result – The dictionary of members defined on the class. User code should not modify the contents of the dict.

Return type


suppress_notifications() Iterator[None][source]

Disable member notifications within in a context.


result – A context manager which disables atom notifications for the duration of the context. When the context exits, the state is restored to its previous value.

Return type


class atom.atom.AtomMeta(name, bases, dct)[source]

Bases: type

The metaclass for classes derived from Atom.

This metaclass computes the memory layout of the members in a given class so that the CAtom class can allocate exactly enough space for the object data slots when it instantiates an object.

All classes deriving from Atom will be automatically slotted, which will prevent the creation of an instance dictionary and also the ability of an Atom to be weakly referenceable. If that behavior is required, then a subclasss should declare the appropriate slots.

class atom.atom.ExtendedObserver(funcname: str, attr: str)[source]

Bases: object

A callable object used to implement extended observers.

exception atom.atom.MissingMemberWarning[source]

Bases: UserWarning

Signal an expected member is not present.

class atom.atom.ObserveHandler(pairs: List[Tuple[str, Optional[str]]])[source]

Bases: object

An object used to temporarily store observe decorator state.

clone() atom.atom.ObserveHandler[source]

Create a clone of the sentinel.

func: Optional[Callable]
funcname: Optional[str]
atom.atom.observe(*names: str)[source]

A decorator which can be used to observe members on a class.


*names – The str names of the attributes to observe on the object. These must be of the form ‘foo’ or ‘’.

class atom.atom.set_default(value: Any)[source]

Bases: object

An object used to set the default value of a base class member.

clone() atom.atom.set_default[source]

Create a clone of the sentinel.