array
import array
This module provides fixed-width typed array classes: twos- complement
integers (Int8Array/UInt8Array through Int64Array/UInt64Array)
and IEEE-754 floating-point numbers (FloatArray, DoubleArray), each
storing its elements packed in the platform byte order. They complement
the bytes object and allow higher-level binary data manipulation
without giving up direct access to the underlying bytes (to_bytes()).
All ten classes share the same interface (indexing, append()/
insert()/remove_at()/set()/pop(), slice(), fill(),
equals(), iteration via for x in arr, and conversion via
to_list()/to_bytes()): see [[array.Int16Array]] for the fully
documented shape every other class in this module follows.
Int64Array/UInt64Array accept and return bigint values (in
addition to plain integers) for anything past what a regular number
can hold exactly: see is_bigint().
Example
import array
var a = array.Int32Array([1, 2, 3])
a.append(4)
for x in a {
echo x
}
echo a.slice(1, 3).to_list() # [2, 3]
The array API
Every public name in array, wherever it is declared. Each links to the
page that documents it.
| Name | Kind | Summary |
|---|---|---|
array.DOUBLE_MAX | constant | Maximum value that “should” exist in a list passed to DoubleArray. |
array.DOUBLE_MIN | constant | Minimum value that “should” exist in a list passed to DoubleArray. |
array.DoubleArray | class | class DoubleArray represents an array of 64-bit IEEE-754 floating-point numbers (doubles) in the platform… |
array.FLOAT_MAX | constant | Maximum value that “should” exist in a list passed to FloatArray. |
array.FLOAT_MIN | constant | Minimum value that “should” exist in a list passed to FloatArray. |
array.FloatArray | class | class FloatArray represents an array of 32-bit IEEE-754 floating-point numbers in the platform byte order. |
array.INT16_MAX | constant | Maximum value that “should” exist in a list passed to Int16Array. |
array.INT16_MIN | constant | Minimum value that “should” exist in a list passed to Int16Array. |
array.INT32_MAX | constant | Maximum value that “should” exist in a list passed to Int32Array. |
array.INT32_MIN | constant | Minimum value that “should” exist in a list passed to Int32Array. |
array.INT64_MAX | constant | Maximum value that “should” exist in a list passed to Int64Array. |
array.INT64_MIN | constant | Minimum value that “should” exist in a list passed to Int64Array. |
array.INT8_MAX | constant | Maximum value that “should” exist in a list passed to Int8Array. |
array.INT8_MIN | constant | Minimum value that “should” exist in a list passed to Int8Array. |
array.Int16Array | class | class Int16Array represents an array of twos-complement 16-bit signed integers in the platform byte order. |
array.Int32Array | class | class Int32Array represents an array of twos-complement 32-bit signed integers in the platform byte order. |
array.Int64Array | class | class Int64Array represents an array of twos-complement 64-bit signed integers in the platform byte order. |
array.Int8Array | class | class Int8Array represents an array of twos-complement 8-bit signed integers. |
array.UINT16_MAX | constant | Maximum value that “should” exist in a list passed to UInt16Array. |
array.UINT32_MAX | constant | Maximum value that “should” exist in a list passed to UInt32Array. |
array.UINT64_MAX | constant | Maximum value that “should” exist in a list passed to UInt64Array. |
array.UINT8_MAX | constant | Maximum value that “should” exist in a list passed to UInt8Array. |
array.UInt16Array | class | class UInt16Array represents an array of twos-complement 16-bit unsigned integers in the platform byte order. |
array.UInt32Array | class | class UInt32Array represents an array of twos-complement 32-bit unsigned integers in the platform byte order. |
array.UInt64Array | class | class UInt64Array represents an array of twos-complement 64-bit unsigned integers in the platform byte order. |
array.UInt8Array | class | class UInt8Array represents an array of twos-complement 8-bit unsigned integers. |
Submodules
| Module | Reached as | Summary |
|---|---|---|
array.double | array.* | DoubleArray: a packed array of double-precision IEEE 754 floats, 8 bytes per element. |
array.float | array.* | FloatArray: a packed array of single-precision IEEE 754 floats, 4 bytes per element. |
array.int16 | array.* | Int16Array: a packed array of twos-complement 16-bit signed integers, 2 bytes per element. |
array.int32 | array.* | Int32Array: a packed array of twos-complement 32-bit signed integers, 4 bytes per element. |
array.int64 | array.* | Int64Array: a packed array of twos-complement 64-bit signed integers, 8 bytes per element. |
array.int8 | array.* | Int8Array: a packed array of twos-complement 8-bit signed integers, 1 byte per element. |
array.uint16 | array.* | UInt16Array: a packed array of unsigned 16-bit integers, 2 bytes per element. |
array.uint32 | array.* | UInt32Array: a packed array of unsigned 32-bit integers, 4 bytes per element. |
array.uint64 | array.* | UInt64Array: a packed array of unsigned 64-bit integers, 8 bytes per element. |
array.uint8 | array.* | UInt8Array: a packed array of unsigned 8-bit integers, 1 byte per element. |
2022, Richard Ore and The Zuri Contributors