jacinle.utils.container#

Module attributes

g

A simple global dict-like object.

Classes

G

A simple container that wraps a dict and provides attribute access to the dict.

GView

A simple container that wraps a dict and provides attribute access to the dict.

OrderedSet

A set that keeps the order of the elements.

SlotAttrObject

Create a object that allows only a fixed set of attributes to be set.

Class G

class G[source]#

Bases: dict

A simple container that wraps a dict and provides attribute access to the dict.

Example

>>> g = G()
>>> g.a = 1
>>> g['b'] = 2
format(sep=': ', end='\n')[source]#

Format the dict as a string using jacinle.utils.printing.kvformat().

print(sep=': ', end='\n', file=None)[source]#

Print the dict using jacinle.utils.printing.kvprint().

Class GView

class GView[source]#

Bases: object

A simple container that wraps a dict and provides attribute access to the dict. In contrast to G, this class wraps around an existing dict.

__init__(dict_=None)[source]#

Initialize the container.

__new__(**kwargs)#
copy()[source]#

Return a shallow copy of the underlying dict.

format(sep=': ', end='\n')[source]#

Format the dict as a string using jacinle.utils.printing.kvformat().

items()[source]#

Iterate over the items of the underlying dict.

keys()[source]#

Return the keys of the underlying dict.

print(sep=': ', end='\n', file=None)[source]#

Print the dict using jacinle.utils.printing.kvprint().

raw()[source]#

Return the underlying dict.

update(other)[source]#

Update the underlying dict with another dict.

values()[source]#

Return the values of the underlying dict.

Class OrderedSet

class OrderedSet[source]#

Bases: object

A set that keeps the order of the elements.

__init__(initial_list=None)[source]#

Initialize the set.

Parameters:

initial_list (Iterable[Any] | None) – the initial list of elements.

__new__(**kwargs)#
append(value)[source]#

Append an element to the set.

as_list()[source]#

Return the elements as a list.

remove(value)[source]#

Remove an element from the set.

Class SlotAttrObject

class SlotAttrObject[source]#

Bases: object

Create a object that allows only a fixed set of attributes to be set.

__init__(**kwargs)[source]#

Initialize the object.

Parameters:

kwargs – the attributes to be set.

__new__(**kwargs)#
clone(deep=False)[source]#

Return a shallow or a deep copy of the object.

Parameters:

deep (bool)

update(**kwargs)[source]#

Update the attributes of the object.