- class atom.atom.Atom¶
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]¶
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]¶
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)¶
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)¶
A callable object used to implement extended observers.
- class atom.atom.ObserveHandler(pairs: List[Tuple[str, Optional[str]]])¶
An object used to temporarily store observe decorator state.
- atom.atom.observe(*names: str)¶
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 ‘foo.bar’.