FixeArray Collection¶
[1]:
from byteclasses.print import byteclass_info, byteclass_inspect
from byteclasses.types.collections import ByteArray
from byteclasses.types.primitives.floats import Float32
from byteclasses.types.primitives.integers import UInt16
[2]:
fa1 = ByteArray(8, UInt16)
fa1[1] = 0xAAAA
fa1[3] = 0xBBBB
fa1[5] = 0xCCCC
fa1[7] = 0xFFFF
byteclass_info(fa1)
byteclass_inspect(fa1)
Byteclass Info ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Property ┃ Value ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ type() │ ByteArray │ │ is_byteclass() │ True │ │ is_collection_instance() │ True │ │ is_primitive_instance() │ False │ │ mro │ ByteArray -> object │ │ len() │ 16 │ │ str() │ (UInt16(0), UInt16(43690), UInt16(0), UInt16(48059), UInt16(0), UInt16(52428), │ │ │ UInt16(0), UInt16(65535)) │ │ repr() │ ByteArray(8, UInt16) │ │ .data │ b'\x00\x00\xaa\xaa\x00\x00\xbb\xbb\x00\x00\xcc\xcc\x00\x00\xff\xff' │ └──────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────┘
╭────────────────── Byteclass Inspect ──────────────────╮ │ 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f │ │ ----------------------------------------------------- │ │ 0x0 |00 00|aa aa|00 00|bb bb|00 00|cc cc|00 00|ff ff │ │ 0x10 │ ╰───────────────────────────────────────────────────────╯
Legend ┏━━━━━━━━┳━━━━━━━┓ ┃ Member ┃ Value ┃ ┡━━━━━━━━╇━━━━━━━┩ │ 0 │ 0 │ │ 1 │ 43690 │ │ 2 │ 0 │ │ 3 │ 48059 │ │ 4 │ 0 │ │ 5 │ 52428 │ │ 6 │ 0 │ │ 7 │ 65535 │ └────────┴───────┘
[3]:
fa2 = ByteArray(8, Float32)
fa2[1] = 0xAAAA
fa2[3] = 0xBBBB
fa2[5] = 0xCCCC
fa2[7] = 0xFFFF
byteclass_info(fa2)
byteclass_inspect(fa2)
Byteclass Info ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Property ┃ Value ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ type() │ ByteArray │ │ is_byteclass() │ True │ │ is_collection_instance() │ True │ │ is_primitive_instance() │ False │ │ mro │ ByteArray -> object │ │ len() │ 32 │ │ str() │ (Float32(0.0), Float32(43690.0), Float32(0.0), Float32(48059.0), Float32(0.0), │ │ │ Float32(52428.0), Float32(0.0), Float32(65535.0)) │ │ repr() │ ByteArray(8, Float32) │ │ .data │ b'\x00\x00\x00\x00\x00\xaa*G\x00\x00\x00\x00\x00\xbb;G\x00\x00\x00\x00\x00\xccLG\x0… │ └──────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────┘
╭────────────────── Byteclass Inspect ──────────────────╮ │ 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f │ │ ----------------------------------------------------- │ │ 0x0 |00 00 00 00|00 aa 2a 47|00 00 00 00|00 bb 3b 47 │ │ 0x10 |00 00 00 00|00 cc 4c 47|00 00 00 00|00 ff 7f 47 │ │ 0x20 │ ╰───────────────────────────────────────────────────────╯
Legend ┏━━━━━━━━┳━━━━━━━━━┓ ┃ Member ┃ Value ┃ ┡━━━━━━━━╇━━━━━━━━━┩ │ 0 │ 0.0 │ │ 1 │ 43690.0 │ │ 2 │ 0.0 │ │ 3 │ 48059.0 │ │ 4 │ 0.0 │ │ 5 │ 52428.0 │ │ 6 │ 0.0 │ │ 7 │ 65535.0 │ └────────┴─────────┘