PyoMapping
Bases: ,
Base trait for eager pyochain immutable mapping collections.
PyoMapping[K, V] is the shared trait for concrete, eager mapping-like
collections such as Dict.
It extends PyoCollection[K] and collections.abc.Mapping[K, V].
This is equivalent to subclassing collections.abc.Mapping[K, V] (this trait
already does), meaning any concrete subclass must implement the required
Mapping dunder methods:
__getitem____iter____len__
On top of the standard Mapping protocol, it provides the additional
pyochain API (from PyoCollection, Pipeable, Checkable, plus any helpers defined here).
Source code in src/pyochain/traits/_iterable.py
2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 | |
items()
Return a view of the Mapping items.
Returns:
| Type | Description |
|---|---|
|
PyoItemsView[K, V]: A view of the dictionary's (key, value) pairs. |
Example:
>>> import pyochain as pc
>>> data = pc.Dict({1: "a", 2: "b"})
>>> data.items()
PyoItemsView(Dict(1: 'a', 2: 'b'))
Source code in src/pyochain/traits/_iterable.py
2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 | |
keys()
Return a view of the Mapping keys.
Returns:
| Type | Description |
|---|---|
|
PyoKeysView[K]: A view of the dictionary's keys. |
Example:
>>> import pyochain as pc
>>> data = pc.Dict({1: "a", 2: "b"})
>>> data.keys()
PyoKeysView(Dict(1: 'a', 2: 'b'))
Source code in src/pyochain/traits/_iterable.py
2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 | |
values()
Return a view of the Mapping values.
Returns:
| Type | Description |
|---|---|
|
PyoValuesView[V]: A view of the dictionary's values. |
Example:
>>> import pyochain as pc
>>> data = pc.Dict({1: "a", 2: "b"})
>>> data.values()
PyoValuesView(Dict(1: 'a', 2: 'b'))
Source code in src/pyochain/traits/_iterable.py
2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 | |