Collection classes and helpers.
Class |
|
A dictionary that is not publicly mutable. |
Class |
|
Dictionary with 'squishy' removal of least recently used items. |
Class |
|
Undocumented |
Class |
|
Provide a __getattr__/__setattr__ interface with an OrderedDict as backing store. |
Class |
|
A dict which populates missing values via a creation function. |
Class |
|
Provide a __getattr__/__setattr__ interface over a dict. |
Class |
|
Provide immutable dict/object attribute to an underlying dictionary. |
Class |
|
A Registry that can store one or multiple instances of a single class on the basis of a "scope" function. |
Class |
|
A :class:`.ScopedRegistry` that uses a ``threading.local()`` variable for storage. |
Class |
|
Appends items to a collection ensuring uniqueness. |
Class |
|
Like PopulateDict, but assumes a self + a method and does not create a reference cycle. |
Class |
|
Undocumented |
Function | coerce |
Undocumented |
Function | coerce |
Undocumented |
Function | flatten |
Given an iterator of which further sub-elements may also be iterators, flatten the sub-elements into a single iterator. |
Function | has |
Given a sequence and search object, return True if there's more than one, False if zero or one of them. |
Function | has |
return True if any items of set\_ are present in iterable. |
Function | merge |
merge two lists, maintaining ordering as much as possible. |
Function | to |
Undocumented |
Function | to |
Undocumented |
Function | to |
Undocumented |
Function | update |
Copy the given dict and update with the given values. |
Constant | EMPTY |
Undocumented |
Constant | EMPTY |
Undocumented |
Class | _ |
Undocumented |
Class | _ |
Undocumented |
Function | _ordered |
Sort an OrderedDict in-place. |
Type Variable | _DT |
Undocumented |
Type Variable | _F |
Undocumented |
Type Variable | _KT |
Undocumented |
Type Variable | _T |
Undocumented |
Type Variable | _ |
Undocumented |
Type Variable | _VT |
Undocumented |
Given an iterator of which further sub-elements may also be iterators, flatten the sub-elements into a single iterator.
Given a sequence and search object, return True if there's more than one, False if zero or one of them.
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.
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