docarray.array.mixins.io.binary module

class docarray.array.mixins.io.binary.BinaryIOMixin[source]

Bases: object

Save/load an array to a binary file.

classmethod load_binary(file)[source]

Load array elements from a LZ4-compressed binary file.

Parameters

file (Union[str, BinaryIO, bytes]) – File or filename or serialized bytes where the data is stored.

Return type

T

Returns

a DocumentArray object

save_binary(file)[source]

Save array elements into a LZ4 compressed binary file.

Comparing to save_json(), it is faster and the file is smaller, but not human-readable.

Note

To get a binary presentation in memory, use bytes(...).

Parameters

file (Union[str, BinaryIO]) – File or filename to which the data is saved.

Return type

None

to_bytes()[source]

Serialize itself into bytes with LZ4 compression.

For more Pythonic code, please use bytes(...).

Return type

bytes

Returns

the binary serialization in bytes