* **It's a richer interface than the basic sequence.**
* **Extending it generates iter(), contains(), reversed(), index() and count().**
* **Unlike `'abc.Iterable'` and `'abc.Collection'`, it is not a duck type. That is why `'issubclass(MySequence, abc.Sequence)'` would return False even if MySequence had all the methods defined. It however recognizes list, tuple, range, str, bytes, bytearray, memoryview and deque, because they are registered as Sequence's virtual subclasses.**
* **Unlike `'abc.Iterable'` and `'abc.Collection'`, it is not a duck type. That is why `'issubclass(MySequence, abc.Sequence)'` would return False even if MySequence had all the methods defined. It however recognizes list, tuple, range, str, bytes, bytearray, array, memoryview and deque, because they are registered as its virtual subclasses.**
**List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Sizes and byte order are always determined by the system.**
**List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.**
```python
from array import array
@ -2054,7 +2054,6 @@ Memory View
<mview>.release() # Releases the object's memory buffer.
```
### Decode
```python
<bytes> = bytes(<mview>) # Returns a new bytes object.
<bytes> = <bytes>.join(<coll_of_mviews>) # Joins mviews using bytes object as sep.
@ -2662,6 +2661,7 @@ import numpy as np
* **Passing a tuple of axes will chain the operations like this: `'<array>.<method>(axis_1).<method>(axis_2 - 1 if axis_2 > axis_1 else axis_2)'`.**
<li><strong>It's a richer interface than the basic sequence.</strong></li>
<li><strong>Extending it generates iter(), contains(), reversed(), index() and count().</strong></li>
<li><strong>Unlike <codeclass="python hljs"><spanclass="hljs-string">'abc.Iterable'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'abc.Collection'</span></code>, it is not a duck type. That is why <codeclass="python hljs"><spanclass="hljs-string">'issubclass(MySequence, abc.Sequence)'</span></code> would return False even if MySequence had all the methods defined. It however recognizes list, tuple, range, str, bytes, bytearray, memoryview and deque, because they are registered as Sequence's virtual subclasses.</strong></li>
<li><strong>Unlike <codeclass="python hljs"><spanclass="hljs-string">'abc.Iterable'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'abc.Collection'</span></code>, it is not a duck type. That is why <codeclass="python hljs"><spanclass="hljs-string">'issubclass(MySequence, abc.Sequence)'</span></code> would return False even if MySequence had all the methods defined. It however recognizes list, tuple, range, str, bytes, bytearray, array, memoryview and deque, because they are registered as its virtual subclasses.</strong></li>
<div><h2id="array"><ahref="#array"name="array">#</a>Array</h2><p><strong>List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Sizes and byte order are always determined by the system.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> array <spanclass="hljs-keyword">import</span> array
<div><h2id="array"><ahref="#array"name="array">#</a>Array</h2><p><strong>List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> array <spanclass="hljs-keyword">import</span> array
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <collection>) <spanclass="hljs-comment"># Array from collection of numbers.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <bytes>) <spanclass="hljs-comment"># Array from bytes object.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <array>) <spanclass="hljs-comment"># Treats array as a sequence of numbers.</span>
<div><h3id="decode-2">Decode</h3><pre><codeclass="python language-python hljs"><bytes> = bytes(<mview>) <spanclass="hljs-comment"># Returns a new bytes object.</span>
<pre><codeclass="python language-python hljs"><bytes> = bytes(<mview>) <spanclass="hljs-comment"># Returns a new bytes object.</span>
<bytes> = <bytes>.join(<coll_of_mviews>) <spanclass="hljs-comment"># Joins mviews using bytes object as sep.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <mview>) <spanclass="hljs-comment"># Treats mview as a sequence of numbers.</span>
<file>.write(<mview>) <spanclass="hljs-comment"># Writes mview to the binary file.</span>
</code></pre></div>
</code></pre>
<pre><codeclass="python language-python hljs"><list> = list(<mview>) <spanclass="hljs-comment"># Returns a list of ints or floats.</span>
<str> = str(<mview>, <spanclass="hljs-string">'utf-8'</span>) <spanclass="hljs-comment"># Treats mview as a bytes object.</span>
<li><strong>Axis is an index of the dimension that gets aggregated. Leftmost dimension has index 0. Summing the RGB image along axis 2 will return a greyscale image with shape (50, 100).</strong></li>
<li><strong>Passing a tuple of axes will chain the operations like this: <codeclass="python hljs"><spanclass="hljs-string">'<array>.<method>(axis_1).<method>(axis_2 - 1 if axis_2 > axis_1 else axis_2)'</span></code>.</strong></li>
<pre><codeclass="bash language-bash hljs"><2d_bools> = <2d_array>><== <el/1d/2d_array><spanclass="hljs-comment"># 1d_array must have size of a row.</span>
<1d/2d_a> = <2d_array>[<2d/1d_bools>] <spanclass="hljs-comment"># 1d_bools must have size of a column.</span>
</code></pre>
<ul>
<li><strong>All examples also allow assignments.</strong></li>
</ul>
<div><h3id="broadcasting">Broadcasting</h3><p><strong>Broadcasting is a set of rules by which NumPy functions operate on arrays of different sizes and/or dimensions.</strong></p><pre><codeclass="python language-python hljs">left = [[<spanclass="hljs-number">0.1</span>], [<spanclass="hljs-number">0.6</span>], [<spanclass="hljs-number">0.8</span>]] <spanclass="hljs-comment"># Shape: (3, 1)</span>