Skip to content

PyoSized

Bases: Sized, ABC


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

              

              click pyochain.abc._collection.PyoSized href "" "pyochain.abc._collection.PyoSized"
            
Source code in src/pyochain/abc/_collection.py
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
class PyoSized(Sized, ABC):
    # pyrefly: ignore [implicit-any-attribute]
    __slots__ = ()  # pyright: ignore[reportUnannotatedClassAttribute]

    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
            >>> data = Dict.from_ref({1: "a", 2: "b"})
            >>> data.len()
            2

            ```
        """
        return len(self)

    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(())
            >>> d.is_empty()
            True
            >>> d.insert(1, "a")
            NONE
            >>> d.is_empty()
            False

            ```
        """
        return len(self) == 0

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(())
>>> d.is_empty()
True
>>> d.insert(1, "a")
NONE
>>> d.is_empty()
False
Source code in src/pyochain/abc/_collection.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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(())
        >>> d.is_empty()
        True
        >>> d.insert(1, "a")
        NONE
        >>> d.is_empty()
        False

        ```
    """
    return len(self) == 0

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
>>> data = Dict.from_ref({1: "a", 2: "b"})
>>> data.len()
2
Source code in src/pyochain/abc/_collection.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
        >>> data = Dict.from_ref({1: "a", 2: "b"})
        >>> data.len()
        2

        ```
    """
    return len(self)