array -- Efficient arrays of numeric data. ========================================== .. This document was autogenerated by Sphinx-autoapi from a .pyi stub or a source code file. .. Do not edit this file, instead edit the source file and run Sphinx to update. .. Source: docs/stubs/array/__init__.pyi .. py:module:: array .. autoapi-nested-parse:: Efficient arrays of numeric data. |see_cpython_module| :mod:`python:array`. Supported format codes: ``b``, ``B``, ``h``, ``H``, ``i``, ``I``, ``l``, ``L``, ``q``, ``Q``, ``f``, ``d`` (the latter 2 depending on the floating-point support). Classes ------- .. autoapisummary:: array.array Module Contents --------------- .. py:class:: array(typecode, iterable: Optional[Any] = None) Bases: :py:obj:`List` Create array with elements of given type. Initial contents of the array are given by *iterable*. If it is not provided, an empty array is created. .. py:method:: __add__(other) -> _typeshed.Incomplete Return a new ``array`` that is the concatenation of the array with *other*, called as ``a + other`` (where ``a`` and *other* are both ``arrays``). **Note:** ``__add__`` cannot be called directly (``a.__add__(other)`` fails) and is not present in ``__dict__``, however ``a + other`` does work. .. py:method:: __getitem__(index) -> List[int] Indexed read of the array, called as ``a[index]`` (where ``a`` is an ``array``). Returns a value if *index* is an ``int`` and an ``array`` if *index* is a slice. Negative indices count from the end and ``IndexError`` is thrown if the index is out of range. **Note:** ``__getitem__`` cannot be called directly (``a.__getitem__(index)`` fails) and is not present in ``__dict__``, however ``a[index]`` does work. .. py:method:: __iadd__(other) -> _typeshed.Incomplete Concatenates the array with *other* in-place, called as ``a += other`` (where ``a`` and *other* are both ``arrays``). Equivalent to ``extend(other)``. **Note:** ``__iadd__`` cannot be called directly (``a.__iadd__(other)`` fails) and is not present in ``__dict__``, however ``a += other`` does work. .. py:method:: __len__() -> int Returns the number of items in the array, called as ``len(a)`` (where ``a`` is an ``array``). **Note:** ``__len__`` cannot be called directly (``a.__len__()`` fails) and the method is not present in ``__dict__``, however ``len(a)`` does work. .. py:method:: __repr__() -> str Returns the string representation of the array, called as ``str(a)`` or ``repr(a)``` (where ``a`` is an ``array``). Returns the string ``"array(, [])"``, where ```` is the type code letter for the array and ```` is a comma separated list of the elements of the array. **Note:** ``__repr__`` cannot be called directly (``a.__repr__()`` fails) and is not present in ``__dict__``, however ``str(a)`` and ``repr(a)`` both work. .. py:method:: __setitem__(index, value) -> _typeshed.Incomplete Indexed write into the array, called as ``a[index] = value`` (where ``a`` is an ``array``). ``value`` is a single value if *index* is an ``int`` and an ``array`` if *index* is a slice. Negative indices count from the end and ``IndexError`` is thrown if the index is out of range. **Note:** ``__setitem__`` cannot be called directly (``a.__setitem__(index, value)`` fails) and is not present in ``__dict__``, however ``a[index] = value`` does work. .. py:method:: append(val) -> _typeshed.Incomplete Append new element *val* to the end of array, growing it. .. py:method:: extend(iterable) -> _typeshed.Incomplete Append new elements as contained in *iterable* to the end of array, growing it.