Skip to content

PyoSized

Bases: Checkable, Protocol


              flowchart TD
              pyochain.abc._collection.PyoSized[PyoSized]
              pyochain.abc._mixins.Checkable[Checkable]

                              pyochain.abc._mixins.Checkable --> pyochain.abc._collection.PyoSized
                


              click pyochain.abc._collection.PyoSized href "" "pyochain.abc._collection.PyoSized"
              click pyochain.abc._mixins.Checkable href "" "pyochain.abc._mixins.Checkable"
            
Source code in pyochain/abc/_collection.pyi
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
@runtime_checkable
class PyoSized(Checkable, Protocol):
    @abstractmethod
    def __len__(self) -> int: ...
    def len(self) -> int:
        """Return the length of `Self`.

        Equivalent to `len(self)`, but as a method.

        Returns:
            int: The number of elements in `Self`.

        Example:
            ```python
            from pyochain import Dict

            assert Dict(a=1, b=2).len() == 2
            ```
        """

    def is_empty(self) -> bool:
        """Returns `True` if the `Collection` contains no elements.

        Returns:
            bool: `True` if the `Collection` is empty, `False` otherwise.

        Example:
            ```python
            from pyochain import Dict

            d = Dict(())
            assert d.is_empty()
            d.insert(1, "a")
            assert not d.is_empty()
            ```
        """

len()

Return the length of Self.

Equivalent to len(self), but as a method.

Returns:

Name Type Description
int int

The number of elements in Self.

Example
from pyochain import Dict

assert Dict(a=1, b=2).len() == 2
Source code in pyochain/abc/_collection.pyi
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def len(self) -> int:
    """Return the length of `Self`.

    Equivalent to `len(self)`, but as a method.

    Returns:
        int: The number of elements in `Self`.

    Example:
        ```python
        from pyochain import Dict

        assert Dict(a=1, b=2).len() == 2
        ```
    """

is_empty()

Returns True if the Collection contains no elements.

Returns:

Name Type Description
bool bool

True if the Collection is empty, False otherwise.

Example
from pyochain import Dict

d = Dict(())
assert d.is_empty()
d.insert(1, "a")
assert not d.is_empty()
Source code in pyochain/abc/_collection.pyi
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def is_empty(self) -> bool:
    """Returns `True` if the `Collection` contains no elements.

    Returns:
        bool: `True` if the `Collection` is empty, `False` otherwise.

    Example:
        ```python
        from pyochain import Dict

        d = Dict(())
        assert d.is_empty()
        d.insert(1, "a")
        assert not d.is_empty()
        ```
    """