module documentation

Collection classes and helpers.

Class FacadeDict A dictionary that is not publicly mutable.
Class LRUCache Dictionary with 'squishy' removal of least recently used items.
Class OrderedIdentitySet Undocumented
Class OrderedProperties Provide a __getattr__/__setattr__ interface with an OrderedDict as backing store.
Class PopulateDict A dict which populates missing values via a creation function.
Class Properties Provide a __getattr__/__setattr__ interface over a dict.
Class ReadOnlyProperties Provide immutable dict/object attribute to an underlying dictionary.
Class ScopedRegistry A Registry that can store one or multiple instances of a single class on the basis of a "scope" function.
Class ThreadLocalRegistry A :class:`.ScopedRegistry` that uses a ``threading.local()`` variable for storage.
Class UniqueAppender Appends items to a collection ensuring uniqueness.
Class WeakPopulateDict Like PopulateDict, but assumes a self + a method and does not create a reference cycle.
Class WeakSequence Undocumented
Function coerce_generator_arg Undocumented
Function coerce_to_immutabledict Undocumented
Function flatten_iterator Given an iterator of which further sub-elements may also be iterators, flatten the sub-elements into a single iterator.
Function has_dupes Given a sequence and search object, return True if there's more than one, False if zero or one of them.
Function has_intersection return True if any items of set\_ are present in iterable.
Function merge_lists_w_ordering merge two lists, maintaining ordering as much as possible.
Function to_column_set Undocumented
Function to_list Undocumented
Function to_set Undocumented
Function update_copy Copy the given dict and update with the given values.
Constant EMPTY_DICT Undocumented
Constant EMPTY_SET Undocumented
Class _CreateFuncType Undocumented
Class _ScopeFuncType Undocumented
Function _ordered_dictionary_sort Sort an OrderedDict in-place.
Type Variable _DT Undocumented
Type Variable _F Undocumented
Type Variable _KT Undocumented
Type Variable _T Undocumented
Type Variable _T_co Undocumented
Type Variable _VT Undocumented
def coerce_generator_arg(arg: Any) -> List[Any]: (source)

Undocumented

def coerce_to_immutabledict(d: Mapping[_KT, _VT]) -> immutabledict[_KT, _VT]: (source)

Undocumented

def flatten_iterator(x: Iterable[_T]) -> Iterator[_T]: (source)

Given an iterator of which further sub-elements may also be iterators, flatten the sub-elements into a single iterator.

def has_dupes(sequence, target): (source)

Given a sequence and search object, return True if there's more than one, False if zero or one of them.

def has_intersection(set_, iterable): (source)

return True if any items of set\_ are present in iterable. Goes through special effort to ensure __hash__ is not called on items in iterable that don't support it.

def merge_lists_w_ordering(a: List[Any], b: List[Any]) -> List[Any]: (source)

merge two lists, maintaining ordering as much as possible. this is to reconcile vars(cls) with cls.__annotations__. Example:: >>> a = ['__tablename__', 'id', 'x', 'created_at'] >>> b = ['id', 'name', 'data', 'y', 'created_at'] >>> merge_lists_w_ordering(a, b) ['__tablename__', 'id', 'name', 'data', 'y', 'x', 'created_at'] This is not necessarily the ordering that things had on the class, in this case the class is:: class User(Base): __tablename__ = "users" id: Mapped[int] = mapped_column(primary_key=True) name: Mapped[str] data: Mapped[Optional[str]] x = Column(Integer) y: Mapped[int] created_at: Mapped[datetime.datetime] = mapped_column() But things are *mostly* ordered. The algorithm could also be done by creating a partial ordering for all items in both lists and then using topological_sort(), but that is too much overhead. Background on how I came up with this is at: https://gist.github.com/zzzeek/89de958cf0803d148e74861bd682ebae

def to_column_set(x: Any) -> Set[Any]: (source)

Undocumented

def to_list(x: Any, default: Optional[List[Any]] = None) -> List[Any]: (source)

Undocumented

def to_set(x): (source)

Undocumented

def update_copy(d, _new=None, **kw): (source)

Copy the given dict and update with the given values.

Undocumented

Value
immutabledict()

Undocumented

Value
frozenset()
def _ordered_dictionary_sort(d, key=None): (source)

Sort an OrderedDict in-place.

Undocumented

Value
TypeVar('_DT',
        bound=Any)

Undocumented

Value
TypeVar('_F',
        bound=Any)

Undocumented

Value
TypeVar('_KT',
        bound=Any)

Undocumented

Value
TypeVar('_T',
        bound=Any)

Undocumented

Value
TypeVar('_T_co',
        covariant=True)

Undocumented

Value
TypeVar('_VT',
        bound=Any)