Package accretive
¶
Module accretive
¶
Accretive data structures.
Accretive data structures can grow at any time but can never shrink. An accretive dictionary accepts new entires, but cannot have existing entries altered or removed. Similarly, an accretive namespace accepts new attributes, but cannot have existing attributes assigned to new values or deleted.
Subpackages with variants of the data structures are available:
accretive.concealment
: Accretive data structures with attributes concealment.accretive.protection
: Protected accretive data structures.accretive.complete
: Protected accretive data structures with attributes concealment.
- class accretive.ABCFactory(name: str, bases: Tuple[type, ...], namespace: MutableMapping[str, Any], docstring: str | None = None, **nomargs: Any)¶
-
Accretive abstract base classes (ABC).
Derived from
type
, this is a metaclass. A metaclass is a class factory class. I.e., it is a class that produces other classes as its instances.Prevents reassignment or deletion of class attributes after they have been assigned. Only assignment of new class attributes is permitted.
Derived from and compatible with
abc.ABCMeta
. The__abstractmethods__
class attribute and the class attributes, whose names start with_abc_
, are exempt from the accretion mechanism so that the internal method abstraction machinery can function correctly.- mro()¶
Return a type’s method resolution order.
- register(subclass)¶
Register a virtual subclass of an ABC.
Returns the subclass, to allow usage as a class decorator.
- class accretive.Class(name: str, bases: Tuple[type, ...], namespace: MutableMapping[str, Any], docstring: str | None = None, **nomargs: Any)¶
Bases:
type
Accretive classes.
Derived from
type
, this is a metaclass. A metaclass is a class factory class. I.e., it is a class that produces other classes as its instances.Prevents reassignment or deletion of class attributes after they have been assigned. Only assignment of new class attributes is permitted.
- mro()¶
Return a type’s method resolution order.
- class accretive.Dictionary(*iterables: Mapping[Hashable, typing_extensions.Any] | Iterable[Tuple[Hashable, typing_extensions.Any]][Mapping[Hashable, Any] | Iterable[Tuple[Hashable, Any]]], **entries: Any[Any])¶
Bases:
Object
Accretive dictionary.
Prevents alteration or removal of dictionary entries after they have been added. Only addition of new dictionary entries is permitted.
Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- copy() Self ¶
Provides fresh copy of dictionary.
- get(key: ~typing.Hashable, default: ~typing_extensions.Any = <object object>) Any[Any] ¶
Retrieves entry associated with key, if it exists.
- update(*iterables: Mapping[Hashable, typing_extensions.Any] | Iterable[Tuple[Hashable, typing_extensions.Any]][Mapping[Hashable, Any] | Iterable[Tuple[Hashable, Any]]], **entries: Any[Any]) Self ¶
Adds new entries as a batch.
- values() ValuesView[Any] ¶
Provides iterable view over dictionary values.
- class accretive.Module(name, doc=None)¶
Bases:
module
Accretive modules.
Derived from
types.ModuleType
, this class is suitable for use as a Python module class.Prevents reassignment or deletion of module attributes after they have been assigned. Only assignment of new module attributes is permitted.
- class accretive.Namespace(*iterables: Mapping[Hashable, typing_extensions.Any] | Iterable[Tuple[Hashable, typing_extensions.Any]][Mapping[Hashable, Any] | Iterable[Tuple[Hashable, Any]]], **attributes: Any[Any])¶
Bases:
Object
Accretive namespaces.
A namespace is an object, whose attributes can be determined from iterables and keyword arguments, at initialization time. The string representation of the namespace object reflects its current instance attributes. Modeled after
types.SimpleNamespace
.Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- class accretive.Object(*posargs: Any, **nomargs: Any)¶
Bases:
object
Accretive objects.
Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- class accretive.ProducerDictionary(producer: Callable[[], typing_extensions.Any][Callable[[], Any]], /, *iterables: Mapping[Hashable, typing_extensions.Any] | Iterable[Tuple[Hashable, typing_extensions.Any]][Mapping[Hashable, Any] | Iterable[Tuple[Hashable, Any]]], **entries: Any[Any])¶
Bases:
Dictionary
Accretive dictionary with default value for missing entries.
Prevents alteration or removal of dictionary entries after they have been added. Only addition of new dictionary entries is permitted.
When an attempt to access a missing entry is made, then the entry is added with a default value. Modeled after
collections.defaultdict
.Prevents reassignment or deletion of instance attributes after they have been assigned. Only assignment of new instance attributes is permitted.
- copy() Self ¶
Provides fresh copy of dictionary.
- get(key: ~typing.Hashable, default: ~typing_extensions.Any = <object object>) Any[Any] ¶
Retrieves entry associated with key, if it exists.
- update(*iterables: Mapping[Hashable, typing_extensions.Any] | Iterable[Tuple[Hashable, typing_extensions.Any]][Mapping[Hashable, Any] | Iterable[Tuple[Hashable, Any]]], **entries: Any[Any]) Self ¶
Adds new entries as a batch.
- values() ValuesView[Any] ¶
Provides iterable view over dictionary values.
Module accretive.aaliases
¶
Abbreviated aliases to accretive data structures.
Similar to Python builtins.
- accretive.aaliases.acabcmeta
alias of
ABCFactory
- accretive.aaliases.acdefaultdict
alias of
ProducerDictionary
- accretive.aaliases.acdict
alias of
Dictionary
- accretive.aaliases.acmodule
alias of
Module
- accretive.aaliases.acnamespace
alias of
Namespace
- accretive.aaliases.acobject
alias of
Object
- accretive.aaliases.actype
alias of
Class
Module accretive.qaliases
¶
Qualified aliases to accretive data structures.
Useful for avoiding namespace collisions from attribute imports.
- accretive.qaliases.AccretiveABCFactory
alias of
ABCFactory
- accretive.qaliases.AccretiveClass
alias of
Class
- accretive.qaliases.AccretiveDictionary
alias of
Dictionary
- accretive.qaliases.AccretiveModule
alias of
Module
- accretive.qaliases.AccretiveNamespace
alias of
Namespace
- accretive.qaliases.AccretiveObject
alias of
Object
- accretive.qaliases.AccretiveProducerDictionary
alias of
ProducerDictionary