Skip to content

PyoMapping

Bases: PyoCollection[K], Mapping[K, V], ABC


              flowchart TD
              pyochain.abc._mappings.PyoMapping[PyoMapping]
              pyochain.abc._collection.PyoCollection[PyoCollection]
              pyochain.abc._iterable.PyoIterable[PyoIterable]
              pyochain.rs.Pipeable[Pipeable]
              pyochain.rs.Into[Into]
              pyochain.rs.Inspect[Inspect]
              pyochain.rs.Checkable[Checkable]
              pyochain.abc._collection.PyoContainer[PyoContainer]
              pyochain.abc._collection.PyoSized[PyoSized]

                              pyochain.abc._collection.PyoCollection --> pyochain.abc._mappings.PyoMapping
                                pyochain.abc._iterable.PyoIterable --> pyochain.abc._collection.PyoCollection
                                pyochain.rs.Pipeable --> pyochain.abc._iterable.PyoIterable
                                pyochain.rs.Into --> pyochain.rs.Pipeable
                
                pyochain.rs.Inspect --> pyochain.rs.Pipeable
                

                pyochain.rs.Checkable --> pyochain.abc._iterable.PyoIterable
                

                pyochain.abc._collection.PyoContainer --> pyochain.abc._collection.PyoCollection
                
                pyochain.abc._collection.PyoSized --> pyochain.abc._collection.PyoCollection
                



              click pyochain.abc._mappings.PyoMapping href "" "pyochain.abc._mappings.PyoMapping"
              click pyochain.abc._collection.PyoCollection href "" "pyochain.abc._collection.PyoCollection"
              click pyochain.abc._iterable.PyoIterable href "" "pyochain.abc._iterable.PyoIterable"
              click pyochain.rs.Pipeable href "" "pyochain.rs.Pipeable"
              click pyochain.rs.Into href "" "pyochain.rs.Into"
              click pyochain.rs.Inspect href "" "pyochain.rs.Inspect"
              click pyochain.rs.Checkable href "" "pyochain.rs.Checkable"
              click pyochain.abc._collection.PyoContainer href "" "pyochain.abc._collection.PyoContainer"
              click pyochain.abc._collection.PyoSized href "" "pyochain.abc._collection.PyoSized"
            

Extends PyoCollection[K] and collections.abc.Mapping[K, V].

Serves as a base class for pyochain mappings, such as Dict.

Any concrete subclass must implement the required Mapping dunder methods:

  • __getitem__
  • __iter__
  • __len__
Source code in src/pyochain/abc/_mappings.py
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
class PyoMapping[K, V](PyoCollection[K], Mapping[K, V], ABC):
    """Extends `PyoCollection[K]` and `collections.abc.Mapping[K, V]`.

    Serves as a base class for pyochain mappings, such as `Dict`.

    Any concrete subclass must implement the required `Mapping` dunder methods:

    - `__getitem__`
    - `__iter__`
    - `__len__`
    """

    # pyrefly: ignore [implicit-any-attribute]
    __slots__ = ()  # pyright: ignore[reportUnannotatedClassAttribute]

    @override
    def keys(self) -> PyoKeysView[K]:
        """Return a view of the `Mapping` keys.

        Returns:
            PyoKeysView[K]: A view of the dictionary's keys.

        Example:
            ```python
            >>> from pyochain import Dict
            >>> data = Dict({1: "a", 2: "b"})
            >>> data.keys()
            PyoKeysView(Dict(1: 'a', 2: 'b'))

            ```
        """
        from .._views import PyoKeysView

        return PyoKeysView(self)

    @override
    def values(self) -> PyoValuesView[V]:
        """Return a view of the `Mapping` values.

        Returns:
            PyoValuesView[V]: A view of the dictionary's values.

        Example:
            ```python
            >>> from pyochain import Dict
            >>> data = Dict({1: "a", 2: "b"})
            >>> data.values()
            PyoValuesView(Dict(1: 'a', 2: 'b'))

            ```
        """
        from .._views import PyoValuesView

        return PyoValuesView(self)

    @override
    def items(self) -> PyoItemsView[K, V]:
        """Return a view of the `Mapping` items.

        Returns:
            PyoItemsView[K, V]: A view of the dictionary's (key, value) pairs.

        Example:
            ```python
            >>> from pyochain import Dict
            >>> data = Dict({1: "a", 2: "b"})
            >>> data.items()
            PyoItemsView(Dict(1: 'a', 2: 'b'))

            ```
        """
        from .._views import PyoItemsView

        return PyoItemsView(self)

items()

Return a view of the Mapping items.

Returns:

Type Description
PyoItemsView[K, V]

PyoItemsView[K, V]: A view of the dictionary's (key, value) pairs.

Example
>>> from pyochain import Dict
>>> data = Dict({1: "a", 2: "b"})
>>> data.items()
PyoItemsView(Dict(1: 'a', 2: 'b'))
Source code in src/pyochain/abc/_mappings.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
@override
def items(self) -> PyoItemsView[K, V]:
    """Return a view of the `Mapping` items.

    Returns:
        PyoItemsView[K, V]: A view of the dictionary's (key, value) pairs.

    Example:
        ```python
        >>> from pyochain import Dict
        >>> data = Dict({1: "a", 2: "b"})
        >>> data.items()
        PyoItemsView(Dict(1: 'a', 2: 'b'))

        ```
    """
    from .._views import PyoItemsView

    return PyoItemsView(self)

keys()

Return a view of the Mapping keys.

Returns:

Type Description
PyoKeysView[K]

PyoKeysView[K]: A view of the dictionary's keys.

Example
>>> from pyochain import Dict
>>> data = Dict({1: "a", 2: "b"})
>>> data.keys()
PyoKeysView(Dict(1: 'a', 2: 'b'))
Source code in src/pyochain/abc/_mappings.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@override
def keys(self) -> PyoKeysView[K]:
    """Return a view of the `Mapping` keys.

    Returns:
        PyoKeysView[K]: A view of the dictionary's keys.

    Example:
        ```python
        >>> from pyochain import Dict
        >>> data = Dict({1: "a", 2: "b"})
        >>> data.keys()
        PyoKeysView(Dict(1: 'a', 2: 'b'))

        ```
    """
    from .._views import PyoKeysView

    return PyoKeysView(self)

values()

Return a view of the Mapping values.

Returns:

Type Description
PyoValuesView[V]

PyoValuesView[V]: A view of the dictionary's values.

Example
>>> from pyochain import Dict
>>> data = Dict({1: "a", 2: "b"})
>>> data.values()
PyoValuesView(Dict(1: 'a', 2: 'b'))
Source code in src/pyochain/abc/_mappings.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@override
def values(self) -> PyoValuesView[V]:
    """Return a view of the `Mapping` values.

    Returns:
        PyoValuesView[V]: A view of the dictionary's values.

    Example:
        ```python
        >>> from pyochain import Dict
        >>> data = Dict({1: "a", 2: "b"})
        >>> data.values()
        PyoValuesView(Dict(1: 'a', 2: 'b'))

        ```
    """
    from .._views import PyoValuesView

    return PyoValuesView(self)